我无法确定Outlook 2013的正确VBA代码,以便在电子邮件打开进行编辑时将固定电子邮件地址添加到电子邮件的BCC字段.我有以下代码,它创建电子邮件,然后设置BCC.
我想将BCC添加到我要回复的电子邮件中,因此该消息已经是"草稿"形式.
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")
Dmitry Streb.. 5
而不是Application.CreateItem(olMailItem)
,使用Application.ActiveInspector.CurrentItem
.如果设置BCC属性,则将清除所有现有BCC收件人.对于每个电子邮件地址,请使用Recipients.Add(您已将其注释掉).