【问题标题】:Outlook 2007 VBA - BCC depending on To/CC RecipientsOutlook 2007 VBA - BCC 取决于收件人/抄送收件人
【发布时间】:2016-06-03 09:02:31
【问题描述】:

我希望创建一个规则,根据收件人/抄送收件人的域名有条件地添加密件抄送收件人。我已经将this 问题确定为类似问题,但似乎尚未解决。

起始代码如下:

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 = "SomeEmailAddress@domain.com"

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

在伪代码中,我希望将以下条件添加到 strBCC 字符串:

If ToCCRecipientDomain = "@example1.co.uk"
  Then strBCC = "email1@trello.com"
ElseIf ToCCRecipientDomain ="@example2.co.uk"
  Then strBCC = "email2@trello.com"
ElseIf ToCCRecipientDomain ="@example3.co.uk"
  Then strBCC = "email3@trello.com"
Else
  Then Cancel = True
End If

对于那些对此应用程序/原因感兴趣的人,我希望在特定项目的 Trello 板上创建一个发送给客户的电子邮件列表,这将取决于发送到的电子邮件地址。

【问题讨论】:

    标签: vba outlook trello


    【解决方案1】:

    我认为我很接近以下内容,只需在需要其他条件时添加额外的 If 和 EndIf 行。

    If InStr(Item.Recipients.Address, "@example1.co.uk") Then
        strBcc = "email1@trello.com"
    If InStr(Item.Recipients.Address, "@example2.co.uk") Then
        strBcc = "email2@trello.com"
    Else
        Cancel = True
    End If
    End If
    

    【讨论】:

    • 我认为问题出在“Item.Recipients.Address” - 我不认为这是调用电子邮件收件人的地址
    猜你喜欢
    • 1970-01-01
    • 2015-05-08
    • 1970-01-01
    • 2014-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-10
    • 1970-01-01
    相关资源
    最近更新 更多