How to send email from my program.

    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.
     
kham762690Asked:
Who is Participating?
 
StefaanConnect With a Mentor Commented:
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
 
intheCommented:
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
 
simonetCommented:
Try this:

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

Yours,

Alex
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
aubsCommented:
Have you looked in the Delphi>demos>internet directory.
Look at the SMTP example
0
 
smurffCommented:
listening
0
 
lanniCommented:
g
0
 
craig_capelCommented:
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
 
smurffCommented:
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
 
jollaCommented:
Regarding the last comment about the 503 error message sounds like there is no address entered in the SMTP.postmessage.toaddress field.
0
 
hennieodCommented:
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
 
kham762690Author Commented:
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
 
kham762690Author Commented:
Comment accepted as answer
0
 
kham762690Author Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.