Solved

How to send email from my program.

Posted on 2000-05-02
13
218 Views
Last Modified: 2012-05-05
    My program will run on NT server(in Domain a) and want to send email with attach a file from my program to user in domain b(this domain has the Exchange server).
     I use delphi4 to implement it but, I don't know what the components that can send email if I have only exchange server on other domain that does not trust with my server domain or which free email server that I can use with primitive component such nmsmtp.
Thank you in advance.
tt-novice.
     
0
Comment
Question by:kham762690
13 Comments
 
LVL 17

Expert Comment

by:inthe
ID: 2770515
how do you normally send mail to domain b?
can you use mapi enabled programs (outlook) etc..
if so then you should be alright with nmsmtp ..
0
 
LVL 15

Expert Comment

by:simonet
ID: 2771499
Try this:

"How to send e-mail and fax from a Delphi application"
http://www.bhnet.com.br/~simonet/howtoprojs.htm

Yours,

Alex
0
 
LVL 3

Accepted Solution

by:
Stefaan earned 100 total points
ID: 2772200
Hi,

One easy way is to use an API call from the ShellAPI unit.  If you are able to send an e-mail (if you have an e-mail client configured) and you want to send an e-mail to User@domain.com then you can use the following instruction :

ShellExecute(ValidParentForm(Self).Handle,'Open', PChar('mailto:User@Domain.con'), nil, nil, SW_SHOWNORMAL);

Normally this should open your default e-mail client and create a new mail which is adressed to User@domain.com.

Using this command won't send the mail automatically though.  The user will have to enter the body and press send.

If you need more MAPI functionality then the sample provided by Alex is worth checking out.  It is simple and well documented.

Best regards,


Stefaan
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 2

Expert Comment

by:aubs
ID: 2772477
Have you looked in the Delphi>demos>internet directory.
Look at the SMTP example
0
 
LVL 3

Expert Comment

by:smurff
ID: 2772697
listening
0
 

Expert Comment

by:lanni
ID: 2773054
g
0
 
LVL 2

Expert Comment

by:craig_capel
ID: 2773593
with nmsmtp1 do
      begin
         postmessage.attachments.addstrings(memo4.lines);
         postmessage.date:=datetostr(now);
         postmessage.FromName:='EE people';
         postmessage.replyTo:='reply@whatever.com';
         postmessage.subject:='Subject';
         postmessage.toaddress.clear;
         postmessage.fromaddress:='Whoever@whoever.com';
         reportlevel:=1;
         userid:='youruserid';
         timeout:=5000; //how long until it gives up
      end;


      nmsmtp1.postmessage.body.clear;
      nmsmtp1.PostMessage.attachments.clear;
      nmsmtp1.PostMessage.toaddress.Add(edit2.text);
          //Add Body
    memo3.clear;
        memo3.lines.add('Dear '+edit1.text);
        memo3.lines.add('');
        memo3.lines.add('Blah Blah Blah, i bet your not intrested one bit');
        memo3.lines.add('');
        memo3.lines.add(Your Name...');
//Finish Body
   nmsmtp1.postmessage.body.add(memo3.text);
     nmsmtp1.connect;  


procedure TForm1.NMSMTP1Connect(Sender: TObject);
begin
label5.caption:='Connected';
nmsmtp1.sendmail;
end;

procedure TForm1.NMSMTP1Success(Sender: TObject);
begin
label5.caption:='Sent Mail!';
end;

Example... thats how to use that primitive component such nmsmtp....


Actually, I like it, easy to use, sends files, what else would you need to do with it?..

Craig C.
0
 
LVL 3

Expert Comment

by:smurff
ID: 2774122
Ive tried the demo that I got with D4 and the above demo and all I got was an error. I can connect fine but when it goes to send the data I get this message.

503 valid RCPT TO<recipient> must precede DATA


Any help anyone?
Thanks
Smurff
0
 

Expert Comment

by:jolla
ID: 2787569
Regarding the last comment about the 503 error message sounds like there is no address entered in the SMTP.postmessage.toaddress field.
0
 

Expert Comment

by:hennieod
ID: 2787602
Relaying is disabled on some mail server's.

Outlook Express won't work and
SMTP won't work.

Have to use the MAPI functions.
0
 

Author Comment

by:kham762690
ID: 2824178
It can send email by use MAPI with profile 0f Microsoft Exchange Server. If you logon the domain that does not trust with domain that Exchange Server locate, you must signon at least one time when it popup the authentication popup window.
   However you can install mail server on your computer and set routing host such as Exchange Server.  
   You will use SMTP service that come with option pack but you must install IIS and use INEWMAIL by import library from CDONTS.DLL or
install third-party smtp mail server (I had tried work with CommuniGate Pro)and you can use nmsmtp in delphi to send your email. In these way I can send email depend on event-driven without operator to watching it.
0
 

Author Comment

by:kham762690
ID: 2929899
Comment accepted as answer
0
 

Author Comment

by:kham762690
ID: 2929900
I'm sorry that I forgot to tell that I want to send email without popupmenu to enter user/password. So This is the answer for my proplem.
It can send email by use MAPI with profile 0f Microsoft Exchange Server. If you logon the domain that does not trust with domain that Exchange Server locate, you must signon at least one time when it popup the authentication popup window.
   However you can install mail server on your computer and set routing host such as Exchange Server.  
   You will use SMTP service that come with option pack but you must install IIS and use INEWMAIL by import library from CDONTS.DLL or
install third-party smtp mail server (I had tried work with CommuniGate Pro)and you can use nmsmtp in delphi to send your email. In these way I can send email depend on event-driven without operator to watching it.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how to center only a line in richedit? 4 56
When i run adoquery my application freezes 26 165
Delphi Yen format 3 31
Firemonkey android show image from resource ? 1 41
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now