Отправить Email через Outlook
Оформил: DeeCo
Автор: http://www.swissdelphicenter.ch
uses
ComObj;
procedure TForm1.Button16Click(Sender: TObject);
const
olMailItem = 0;
olByValue = 1;
var
OutlookApp, MailItem, MyAttachments: OLEVariant;
begin
try
OutlookApp := GetActiveOleObject('Outlook.Application');
except
OutlookApp := CreateOleObject('Outlook.Application');
end;
try
MailItem := OutlookApp.CreateItem(olMailItem);
MailItem.Recipients.Add('YourMailAddress@something.com');
MailItem.Subject := 'Your Subject';
MailItem.Body := 'Your Message';
myAttachments := MailItem.Attachments;
myAttachments.Add('C:\SomeFile.txt', olByValue, 1, 'Name of Attachment');
MailItem.Send;
finally
myAttachments := VarNull;
OutlookApp := VarNull;
end;
end;
|