Quote
> I must send e-mail with attachment file.
> I don't know, i can do.
> e.g
> e-mail and subject:
> mailto:a...@asa.cxcx?subject=TEST
> and how must be:
> mail & attachment file
To create a message in your mailing app from your Delphi code, you can:
1. create a message via default mailer using shell api:
uses ShellAPI;
var
pCh: PChar;
begin
pCh := 'mailto:ca...@msn.com?subject=your_subject&body=your_body';
ShellExecute(0, 'open', pCh, nil, nil, SW_SHOWNORMAL);
end;
Some mailers supports the extended syntax with some usefule features. For
example, the MS Outlook supports the file attachment via ShellExecute.
var
pCh: PChar;
begin
pCh :=
'mailto:ca...@msn.com?subject=your_subject&body=your_body&file="c:\autoexec.
bat"';
ShellExecute(0, 'open', pCh, nil, nil, SW_SHOWNORMAL);
end;
But other mailers don't supports this file attachment. You must convert a
texts which you want to place into subject or body - to change a spaces into
"%20". On some builds of MS Windows the all characters from subject and
body will be trancated to small length or converted to lower case.
Create a message in Outlook using OLE:
const
olMailItem = 0;
var
Outlook, MailItem: OLEVariant;
begin
try
Outlook := GetActiveOleObject('Outlook.Application');
except
Outlook := CreateOleObject('Outlook.Application');
end;
MailItem := Outlook.CreateItem(olMailItem);
MailItem.Recipients.Add('ca...@msn.com');
MailItem.Subject := 'your subject';
MailItem.Body := 'Welcome to my homepage: http://www.msn.com';
MailItem.Attachments.Add('C:\Windows\Win.ini');
MailItem.Send;
Outlook := Unassigned;
end;
If you want to create a message in html-format, you can use the HTMLBody
property instead a Body. But note that this HTMLBody property is available
staring from Outlook 98 only.
BTW the email addy isn't mine...
I hope this helps... I found it somewhere on the net and saved it for use
later... Aren't you glad I did?