1 2 unit Unit1; 3 4 interface 5 6 uses 7 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 8 Dialogs, StdCtrls,ComObj; 9 10 type 11 TForm1 = class(TForm) 12 Button1: TButton; 13 procedure Button1Click(Sender: TObject); 14 private 15 { Private declarations } 16 public 17 { Public declarations } 18 end; 19 20 var 21 Form1: TForm1; 22 23 implementation 24 25 {$R *.dfm} 26 27 procedure SendOutlookMail; 28 const 29 olMailItem = 0; 30 var 31 Outlook: OleVariant; 32 vMail: variant; 33 begin 34 try 35 Outlook := GetActiveOleObject('Outlook.Application'); 36 except 37 Outlook := CreateOleObject('Outlook.Application'); 38 end; 39 vMail := Outlook.CreateItem(olMailItem); 40 vMail.Recipients.Add('Test@Programmer.com'); 41 vMail.Subject := 'DevSuperPage'; 42 vMail.Body := 'This is a test'; 43 vMail.Attachments.Add('C:\test.text'); 44 vMail.Send; 45 46 VarClear(Outlook); 47 end; 48 49 procedure TForm1.Button1Click(Sender: TObject); 50 begin 51 SendOutlookMail; 52 end; 53 54 end. 55