在Outlook 2013中使用VBA添加BCC

我无法找出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(上面已有注释)。

链接地址: http://www.djcxy.com/p/77185.html

上一篇: Add BCC to email with VBA in Outlook 2013

下一篇: Generate a valid expression that computes to given N