我的约会中有一个自定义表单,其中有一个CommandButton和一个BCC字段。
当用户按下我的commandButton时,我想向“密件抄送”字段中添加邮件。
当前,我有以下内容:
Sub CommandButton1_Click()
Set test = Item.Recipients.Add('alice@yahoo.com')
test = (int)Outlook.OlMailRecipientType.olBCC;
Item.Recipients.ResolveAll();
End Sub
我尝试了几种不同的方法,没有任何运气。
到目前为止,我仅设法添加了一个标准收件人,即
Sub CommandButton1_Click()
Set oMsg = Application.ActiveInspector.CurrentItem
With oMsg
.Recipients.Add("test")
End With
结束字幕
但是添加密件抄送邮件似乎更麻烦
因此,如何在命令按钮单击时向“密件抄送”字段中添加邮件?
答案 0 :(得分:0)
尝试使用此语法设置收件人的Type
属性,然后解决所有问题。
Sub CommandButton1_Click()
Set test = Item.Recipients.Add("alice@yahoo.com")
test.Type = olBCC
Item.Recipients.ResolveAll()
End Sub
在您的方法中,您尝试将Item
设置为整数(从BCC类型广播),而不是设置Type
的{{1}}属性
答案 1 :(得分:0)
您似乎只需要修改该项目的Recipients
集合:
Sub CommandButton1_Click()
Dim recip as Outlook.Recipient
Set recip = Item.Recipients.Add('alice@yahoo.com')
recip.Type = Outlook.OlMailRecipientType.olBCC;
Item.Recipients.ResolveAll();
End Sub
请注意,MeetingItem接收者可以是下列OlMeetingRecipientType
常量之一:olOptional
,olOrganizer
,olRequired
或olResource
。
很可能您必须创建一个新的MailItem并将其作为密件抄送单独发送出去。
答案 2 :(得分:0)
由于某种原因,Item.Recipients.ResolveAll()
方法不起作用。因此,我跳过了写变量的操作,而是将类型连接为.Recipients.Add()
。
Function CommandButton1_Click()
Set oMsg = Application.ActiveInspector.CurrentItem
With oMsg
.Recipients.Add(Mail).Type = 3
End With
End Function
以下工作原理,并且可以与多个收件人重复进行。