DelphiFAQ Home Search:
General :: Programming :: Delphi :: Network
Network (local network and Internet) programming under Windows with Delphi.

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Featured Article

Sending an email from Delphi with Outlook

Outlook can be easily controlled through OLE. Try the sample procedure SendOutlookMail() from below.

This does not work with Outlook Express - you can find more information on Outlook OLE automation at http://www.djpate.freeserve.co.uk/AutoOutl.htm.

program MailWithOutlook;
 
 procedure SendOutlookMail;
 const
   olMailItem = 0;
 var
   Outlook: OleVariant;
   vMailItem: variant;
 begin
   try
     Outlook := GetActiveOleObject('Outlook.Application');
   except
     Outlook := CreateOleObject('Outlook.Application');
   end;
   vMailItem := Outlook.CreateItem(olMailItem);
   vMailItem.Recipients.Add('dummy@hotmail.com');
   vMailItem.Subject := 'test email';
   vMailItem.Body := 'This is a test';
   vMailItem.Attachments.Add('C:\temp\sample.txt');
   vMailItem.Send;
 
   VarClear(Outlook);
 end;
 
 begin
 
 end.
You don't like the formatting? Check out SourceCoder then!
Generated 12:01:21 on Sep 21, 2017