vba - Outlook 2007 中的 ItemSend 事件中的密件抄送不再有效

标签 vba email outlook bcc

我在 ItemSend 中插入了代码并保存了 ThisOutlookSession 模块。它工作了一次,不再工作。它被保存为 VBAproject.OTM 并且在我重新启动 Outlook 后打开模块时仍然存在。

Private Sub Application_ItemSend(ByVal Item As Object, _
                                 Cancel As Boolean)
    Dim objRecip As Recipient
    Dim strMsg As String
    Dim res As Integer
    Dim strBcc As String
    On Error Resume Next

    ''# #### USER OPTIONS ####
    ''# address for Bcc -- must be SMTP address or resolvable
    ''# to a name in the address book
    strBcc = "someone@somewhere.dom"

    Set objRecip = Item.Recipients.Add(strBcc)
    objRecip.Type = olBCC
    If Not objRecip.Resolve Then
        strMsg = "Could not resolve the Bcc recipient. " & _
                 "Do you want still to send the message?"
        res = MsgBox(strMsg, vbYesNo + vbDefaultButton1, _
                "Could Not Resolve Bcc Recipient")
        If res = vbNo Then
            Cancel = True
        End If
    End If

    Set objRecip = Nothing
End Sub

最佳答案

在项目的主题字段上使用和 if 语句

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)

If Item.Subject = "exact match" Then

    strBcc = "someone@somewhere.dom"

    Set objRecip = Item.Recipients.Add(strBcc)
    objRecip.Type = olBCC
    If Not objRecip.Resolve Then
        strMsg = "Could not resolve the Bcc recipient. " & _
                 "Do you want still to send the message?"
        res = MsgBox(strMsg, vbYesNo + vbDefaultButton1, _
                "Could Not Resolve Bcc Recipient")
        If res = vbNo Then
            Cancel = True
        End If


    End If
    Item.Save

    Set objRecip = Nothing


End If

或者如果你想在主题中包含一个单词,请使用
If InStr(Item.Subject, "BCCSubject") = 0 Then


End If

关于vba - Outlook 2007 中的 ItemSend 事件中的密件抄送不再有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2522884/

相关文章:

excel - 从无法送达的电子邮件正文中提取文本字符串到 Excel

Android:在 htc Hero 上选择 Gmail 应用程序时,带有 EXTRA_STREAM 的 Intent.ACTION_SEND 不会附加任何图像

HTML 电子邮件无间距

Delphi在outlook msg中显示嵌入图像

android - 用于从另一个应用程序打开 Outlook Groups 应用程序的深度链接

vba - Excel VBA - 添加具有特定标题名称的新表列

vba - 工作表中列的动态显示

sql - 无论如何将SQL查询提取到Excel中

python - 如何检测退回邮件

javascript - 该网站如何在没有任何权限的情况下控制用户在选项卡之间的导航?