Solved

How to send email from my program.

Posted on 2000-05-02
13
215 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

758 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

19 Experts available now in Live!

Get 1:1 Help Now