在Outlook 2013中使用VBA将电子邮件添加密件抄送 [英] Add BCC to email with VBA in Outlook 2013

查看:154
本文介绍了在Outlook 2013中使用VBA将电子邮件添加密件抄送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法找出Outlook 2013的正确VBA代码,以便在打开电子邮件进行编辑时将固定的电子邮件地址添加到电子邮件的密件抄送"字段中.我有以下代码,该代码创建电子邮件,然后设置密件抄送.

I can't figure out the correct VBA code for Outlook 2013 to add a fixed email address to the BCC field of an email while it is open for editing. I have the following code, which creates the email and then sets the BCC.

我想在要回复的电子邮件中添加密件抄送,因此该邮件已经采用草稿"格式.

I want to add BCC to emails that I am replying to, so the message will already be in 'draft' form.

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

*更新*

我落实了德米特里的伟大建议

I implemented the great advice from Dmitry

我的代码现在显示为:

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'对象必需",并且高亮显示了这一行:

However, when I try to run it I get an error "Run Time error '424' Object required" and it highlights the line:

Set objRecip = item.Recipients.Add("xxx@example.com")

推荐答案

使用Application.ActiveInspector.CurrentItem代替Application.CreateItem(olMailItem). 如果设置了密件抄送"属性,则将清除所有现有的密件抄送"收件人.对每个电子邮件地址使用Recipients.Add(在上面已注释掉).

Instead of Application.CreateItem(olMailItem), use Application.ActiveInspector.CurrentItem. If you set the BCC property, you will wipe out all existing BCC recipients. Use Recipients.Add (you have it commented out above) for each email address.

这篇关于在Outlook 2013中使用VBA将电子邮件添加密件抄送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆