我希望创建一个规则,根据To / CC收件人的域名有条件地添加BCC收件人。我已经将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 Board客户端的电子邮件列表,这将取决于发送到的电子邮件地址。
答案 0 :(得分:0)
我认为我接近这一点,只需添加额外的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