将密件抄送添加到电子邮件

将密件抄送添加到电子邮件

本文介绍了在 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 = "[email protected]; [email protected]"

    .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("[email protected]")
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("[email protected]")

推荐答案

代替 Application.CreateItem(olMailItem),使用 Application.ActiveInspector.CurrentItem.如果您设置 BCC 属性,您将清除所有现有的 BCC 收件人.为每个电子邮件地址使用 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 将密件抄送添加到电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 00:03