OZ8*_*8HP 7 delphi outlook mailing
我想在Outlook中创建一个带附件的邮件并在发送之前显示它,但我想我已经尝试了几乎我在网上找到的所有样本而没有任何运气.我可以使用Indy,但我非常希望使用Outlook来确保邮件是正确的,因为它是供业务使用的.
函数的任何输入,将地址,主题,消息和附件作为参数,然后在发送之前在Outlook中显示消息.
Ser*_*yuz 14
uses
comobj;
..
procedure DisplayMail(Address, Subject, Body: string; Attachment: TFileName);
var
Outlook: OleVariant;
Mail: Variant;
const
olMailItem = $00000000;
begin
try
Outlook := GetActiveOleObject('Outlook.Application');
except
Outlook := CreateOleObject('Outlook.Application');
end;
Mail := Outlook.CreateItem(olMailItem);
Mail.To := Address;
Mail.Subject := Subject;
Mail.Body := Body;
if Attachment <> '' then
Mail.Attachments.Add(Attachment);
Mail.Display;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
DisplayMail('mailaddress', 'subject', 'message', 'attachmentfile');
end;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10140 次 |
| 最近记录: |