在Outlook中创建带有附件的邮件并显示 [英] Creating a mail with attachment in Outlook and displaying it

查看:513
本文介绍了在Outlook中创建带有附件的邮件并显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Outlook中创建一个带有附件的邮件,并在发送之前显示它,但是我想我已经尝试了几乎在网上找到的所有示例,但没有任何运气. 我可以使用Indy,但是我非常想使用Outlook来确保邮件正确无误,因为它是用于商业用途的.

I want to create a mail with attachment in Outlook and display it before sending it, but I think I have tried almost every sample I have found on the net without any luck. I could use Indy, but I would very much like to use Outlook to be sure that the mail is proper because it is for business use.

以地址",主题",邮件"和附件"为参数,然后在发送之前在Outlook中显示邮件的功能的任何输入.

Any input for a function that takes Address, subject, message and attachment as parameters and then displays the message in Outlook before sending it.

推荐答案

请参见 MailItem.Display方法.

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;

这篇关于在Outlook中创建带有附件的邮件并显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆