1. Home
  2. Computing & Technology
  3. Delphi Programming

Send an email (with attachment) from Outlook

By , About.com Guide

The following code can be used to send an Outlook e-mail message from Delphi:

~~~~~~~~~~~~~~~~~~~~~~~~~
const olMailItem = 0;
var Outlook: OLEVariant;
     MailItem: Variant;
begin
  try
   Outlook:=GetActiveOleObject('Outlook.Application') ;
  except
   Outlook:=CreateOleObject('Outlook.Application') ;
  end;
  MailItem := Outlook.CreateItem(olMailItem) ;
  with MailItem do begin
   Recipients.Add('delphi.guide@about.com') ;
   Subject := 'Subject: Outlook Mail From Delphi';
   Body := 'Welcome to my homepage:
http://delphi.about.com';
   Attachments.Add('C:\Windows\Win.ini') ;
   Send;
  end; {with}
   Outlook := Unassigned;
end;
~~~~~~~~~~~~~~~~~~~~~~~~~

Delphi tips navigator:
» Controling sound volume from code
« How to "HotTrack" any control

Explore Delphi Programming
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Coding Delphi Applications
  5. Delphi Tips and Tricks
  6. 2000 Delphi Tips
  7. Send an email (with attachment) from Outlook

©2009 About.com, a part of The New York Times Company.

All rights reserved.