Solved

How to send email from my program.

Posted on 2000-05-02
13
220 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

730 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