问题描述
帖子的答案在Delphi中使用Outlook有何不同比其他电子邮件客户端好?见下文.
使用此示例,您将如何添加抄送和密件抄送收件人?
Using this example how would you go about adding CC and BCC recipients?
USES OleCtrls, ComObj;
procedure TForm1.Button1Click(Sender: TObject);
const
olMailItem = 0;
var
Outlook: OLEVariant;
MailItem: Variant;
MailInspector : Variant;
stringlist : TStringList;
begin
try
Outlook:=GetActiveOleObject('Outlook.Application') ;
except
Outlook:=CreateOleObject('Outlook.Application') ;
end;
try
Stringlist := TStringList.Create;
MailItem := Outlook.CreateItem(olMailItem) ;
MailItem.Subject := 'subject here';
MailItem.Recipients.Add('[email protected]');
MailItem.Attachments.Add('c:\boot.ini');
Stringlist := TStringList.Create;
StringList.Add('body here');
MailItem.Body := StringList.text;
MailInspector := MailItem.GetInspector;
MailInspector.display(true); //true means modal
finally
Outlook := Unassigned;
StringList.Free;
end;
end;
推荐答案
Recipients
Add()
方法>集合会创建并返回一个新的 Recipient
对象.的 Type
属性Recipient
类允许设置代表接收者类型的整数.对于MailItem
收件人,它可以是以下OlMailRecipientType 常数:olBCC
,olCC
,olOriginator
或olTo
.新邮件收件人的默认Type
是olTo
.
The Add()
method of the Recipients
collection creates and returns a new Recipient
object. The Type
property of the Recipient
class allows to set an integer representing the type of recipient. For MailItem
recipients, it can be one of the following OlMailRecipientType constants: olBCC
, olCC
, olOriginator
, or olTo
. The default Type
for a new mail recipient is olTo
.
MailItem.Recipients.Add('[email protected]'); // Type=1 olTo
MailItem.Recipients.Add('[email protected]').Type := 2; // olCC
MailItem.Recipients.Add('[email protected]').Type := 3; // olBCC
您可能会找到操作方法:以编程方式在Outlook中填充TO,CC和BCC字段对本文很有帮助.
You may find the How To: Fill TO,CC and BCC fields in Outlook programmatically article helpful.
这篇关于Delphi-添加密件抄送& CC收件人到OLE Outlook对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!