Activex OLE Delphi

uses
comobj;
procedure SendMail(Recipients, Attachments: TStringList; Subject, Body: string);
const
// OlItemType sabitleri
// mail, not, kisi vs.
olMailItem = 0;
olAppointmentItem = 1;
olContactItem = 2;
olTaskItem = 3;
olJournalItem = 4;
olNoteItem = 5;
olPostItem = 6;
// OlAttachmentType constants
olByValue = 1;
olByReference = 4;
olEmbeddedItem = 5;
olOLE = 6;
var
myOlApp, myItem: OleVariant;
i: integer;
begin
myOlApp := CreateOLEObject('Outlook.Application');
myItem := myOlApp.CreateItem(olMailItem);
myItem.Subject := Subject;
for i := 0 to Recipients.Count - 1 do
myItem.Recipients.Add(Recipients[i]);
for i := 0 to Attachments.Count - 1 do
myItem.Attachments.Add(Attachments[i], olByValue, 1, Attachments[i]);
myItem.Body := Body;
myItem.Send;
myOlApp := VarNull;
myItem := VarNull;
end;
// kullanimi:
procedure TForm1.Button1Click(Sender: TObject);
var Alicilar, Dosyalar: TStringList;
begin
Alicilar := TStringList.Create;
Alicilar.Add('destek@delphiturk.com');
Alicilar.Add('tansu@delphiturk.com');
Dosyalar := TStringList.Create;
Dosyalar.Add('C:\autoexec.bat');
Dosyalar.Add('C:\config.sys');
try
SendMail(Alicilar, Dosyalar, 'Deneme Mail, Autoexec.bat ve config.sys', Memo1.Lines.Text);
finally
Alicilar.Free;
Dosyalar.Free;
end;
end;