Solved

automatically sending mail through Delphi

Posted on 1999-01-03
14
164 Views
Last Modified: 2010-05-18
I'm using Delphi 3 and I was wondering if there is a way to automatically send an email through my program

My program creates a file, and I would like it to be emailed automatically once created...is there a way to do this...ie automatically send the email to a specified address

If so, how?
If someone is willing to help me with this all the way throught (code etc...) I would be willing to up the points too...

thanks in advance
0
Comment
Question by:rafy
  • 3
  • 2
  • 2
  • +7
14 Comments
 
LVL 10

Expert Comment

by:viktornet
ID: 1354357
Hello Rafy!

There isn't a way to do that with a function, but you should you write your own code by using components and such... try the DSP (Delphi Super Site) and check out the components there...

YOu can open the e-mail browser though...here is how...

ShellExecute(0, 'open', 'mailto:viktor@megsinet.net', 'TheSubject', nil, SW_NORMAL);

Don't forget to include the ShellAPI to your uses clause...

-Viktor
--Ivanov
0
 
LVL 5

Expert Comment

by:scrapdog
ID: 1354358
There is an excellent set of components at http://www.rtfm.be/fpiette/
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1354359
Or you could use the TSMTP component

Raymond.

0
 
LVL 4

Expert Comment

by:StevenB
ID: 1354360
 Download the Internet Mail Suite from

  http://www.argosoft.com/

  these are the easiest/best mailing components I've found. If you decide to use them then I'll be happy to help you with any problems.

  Steven
0
 
LVL 17

Expert Comment

by:inthe
ID: 1354361
here is procedure i use
just place a button,2 edits and a memo on form to test:

procedure TForm1.Button1Click(Sender: TObject);
Var
Buffer : String;
recip,subj,mess : String;
begin
recip:= Edit1.text;   {message recipients email address}
subj:=Edit2.Text;     {message subject}
Mess:= Memo1.Text;    {message}
Buffer:='mailto:'+recip+'?subject='+subj+'&body='+mess;
ShellExecute(Application.Handle,'open',PCharBuffer),nil,nil,SW_Normal);
Sleep(500);              {give mail prog time to open}
keybd_Event(VK_MENU, 0, 0, 0);  {get email prog menu}
keybd_Event(ord('S'), 0, 0, 0);  {s for send}
keybd_Event(ord('S'), 0, KEYEVENTF_KEYUP, 0); {click}
keybd_Event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);  {exit menu}
Edit1.Clear;        
Edit2.Clear;     {and clean up}
Memo1.Clear;    
end;

This will take the params (recipient,subject,and message)and send the mail if you are connected to server if your not connected it places mail in outbox folder
almost all mail progs have s for send mail and i have used this on many pc's without fault.
Regards Barry
0
 
LVL 17

Expert Comment

by:inthe
ID: 1354362
whoops missed a  bracket
 
ShellExecute                    
(Application.Handle,'open',PChar ( Buffer),nil,nil,SW_Normal);

Regards Barry
   
0
 
LVL 7

Expert Comment

by:jconde
ID: 1354363
rafy, scrapdog gave you the url for a really good set of freeware-source included components.  In ICS there are plenty of examples including a smtp demo program.

I suggest you download ICS from the url scrapdog stated, and check the code.....it's quite simple.

Regards,

Jorge
0
What Security Threats Are You Missing?

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.

 
LVL 5

Expert Comment

by:scrapdog
ID: 1354364
It was so easy to learn, I was up and running in 10 minutes.  I am definitely going to send the guy a postcard.
0
 
LVL 1

Expert Comment

by:skatan187
ID: 1354365
like scrapdog said,
http://www.rtfm.be/fpiette/ .. ICS (internet component suite..)

chECk oUt the smtp component.. Use a mail-server (mail.internetprovider.countrycode as server)

sk
0
 

Expert Comment

by:ptiemann2
ID: 1354366
Hi Rafy,
if you try this mailto: stuff with ShellExecute..
be aware of that it depends on the registry and (typically) the email client software whether it every will be sent.
MS-IE installs Outlook Express to handle mailto: but Netscape does not (but an entry in the registry can do it for you).
However, you still depend on the correct installation/ configuration of the mail client. Better use MAPI or a native SMTP component.
0
 

Author Comment

by:rafy
ID: 1354367
Ok...sorry for the delay but I've been really busy...

I can't say the shellexec is the best solution for this sorry...

I'll have to go with scrapdog's and jconde suggestions

I downloaded the ICS suite, and I think it will do the job, but I'll give the points after I finish the program...if it works and I don't need any more help...great..150 points are all yours...If I need more help before it works...I'll award more points (I figure keeping the question open is the easiest way to keep in touch will all the experts!)

Hope this doesn't bug anyone...

0
 
LVL 1

Expert Comment

by:frla0000
ID: 1354368
Hi,

If you want to send a RTF file (formatted text) using MAPI (Exchange, Outlook et c) I can provide you with a finished solution.
I have a DLL and a wrapper for this. Just call a function and you are away. Pretty simple. It took me a lot of research and development to complete it so I can't give you the source to the DLL but the DLL and pascal file you can get.

Otherwise I would suggest you to use TEmail available on http://www.econos.de that also uses MAPI.

Mail me on fredrik.larsson@larsson.tc if you want the DLL.

Regards, Fredrik Larsson.
0
 

Author Comment

by:rafy
ID: 1354369
works great!
waiting for scrapdog to lock the question so I can give him his points.


rafy
0
 
LVL 5

Accepted Solution

by:
scrapdog earned 150 total points
ID: 1354370
Thanks.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

760 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

18 Experts available now in Live!

Get 1:1 Help Now