我无法找出Outlook 2013的正确VBA代码,以在打开电子邮件进行编辑时将固定的电子邮件地址添加到电子邮件的“密件抄送”字段中。我有以下代码,该代码创建电子邮件,然后设置密件抄送。
我想在要回复的电子邮件中添加密件抄送,因此该邮件已经采用“草稿”形式。
Sub sendcomment_click()
Set oMsg = Application.CreateItem(olMailItem)
With oMsg
.Recipients.Add ("email address")
'Set objRecip = Item.Recipients.Add("email address")
'objRecip.Type = olBCC
'objRecip.Resolve
' Join Email addresses by "; " into ".BCC" as string
.BCC = "Person.A@somewhere.com; Person.B@somewhere.com"
.Subject = "New Comment by"
.Body = "sdfsdfsdf"
.Display ' Comment this to have it not show up
'.Send ' Uncomment this to have it sent automatically
End With
Set oMsg = Nothing
End Sub
*更新*
我落实了德米特里的好建议
我的代码现在显示为:
Sub BCC()
Dim objRecip As Recipient
Set oMsg = Application.ActiveInspector.CurrentItem
With oMsg
Set objRecip = item.Recipients.add("XXX@example.com")
objRecip.Type = olBCC
objRecip.Resolve
End With
Set oMsg = Nothing
End sub
但是,当我尝试运行它时,出现错误“运行时错误'424'对象必需”,并突出显示了以下行:
Set objRecip = item.Recipients.Add("xxx@example.com")
最佳答案
代替Application.CreateItem(olMailItem)
,使用Application.ActiveInspector.CurrentItem
。
如果设置了“密件抄送”属性,则将清除所有现有的“密件抄送”收件人。对每个电子邮件地址使用Recipients.Add
(在上面已注释掉)。
关于vba - 在Outlook 2013中使用VBA将电子邮件添加密件抄送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21365624/