`

Sending an email from Delphi with Outlook

阅读更多

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.
分享到:
评论
1 楼 yajie 2009-05-02  
请问LZ,为什么会出现“无效的类别字符串”呢?

相关推荐

Global site tag (gtag.js) - Google Analytics