Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How does one attach a file to e-mail?

Status
Not open for further replies.

delphiman

Programmer
Dec 13, 2001
422
ZA
I have a routine whereby I send email in which I have the following code.

strMsg := 'mailto:' + 'delphiman@bigpond.com' + '?Subject=' + 'REGISTRATION'+ ' ' + strProduct;

Which works fine.

Now I need to know what code to add to it so that the resulting e-mail will attach (say)
c:\h\MyFile.gdb
in the "Ättached" section of the e-mail.

I have tried the following from which I get an exception at c of c:\h

strMsg := 'mailto:' + 'delphiman@bigpond.com' + '?Subject=' + 'REGISTRATION'+ ' ' + strProduct
+ '?Attached=' + c:\h\MyFile.gdb;


Any suggestions please?

Thanks in advance.


 
As far as I am aware, not all mail applications are capable of handling attachments in the mailto line. But what you could try is this:
Code:
var
  pCh: PChar;
begin
  pCh := 'mailto:me@me.com?subject=your_subject&body=your_body&file="c:\temp\myFile.txt"';
  ShellExecute(0, 'open', pCh, nil, nil, SW_SHOWNORMAL);
end;
I found this on:
Also check out my FAQ on this subject - it includes info on the mailto protocol and other methods of emailing:
faq102-3600

Hope this helps!

Clive [infinity]
Ex nihilo, nihil fit (Out of nothing, nothing comes)
 
Just as a further note: if your routine will be run on many different Windows platforms or on different mail applications, your best bet is to use MAPI (Messaging Application Programming Interface) as specified in the FAQ.

Clive [infinity]
Ex nihilo, nihil fit (Out of nothing, nothing comes)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top