?
Solved

How to send email from my program.

Posted on 2000-05-02
13
Medium Priority
?
227 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 300 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month12 days, 11 hours left to enroll

777 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