[英]Outlook 2007 VBA - BCC depending on To/CC Recipients
我希望創建一個規則,該規則將根據 To/CC 收件人的域名有條件地添加 BCC 收件人。 我已經將這個問題確定為類似的問題,但似乎尚未解決。
起始代碼如下:
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 上創建發送給客戶的電子郵件列表,這取決於發送到的電子郵件地址。
我想我很接近這個,如下所示,只需在需要額外條件時添加額外的 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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.