I put the same code in outlook 2013 VBA editor which was executed perfectly in outlook 2010, but in outlook 2013 only execute bcc code, the exception (if) part does not work:
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
If Item.To = "abc@abc.com" Then
Exit Sub
' #### USER OPTIONS ####
' address for Bcc -- must be SMTP address
' or resolvable to a name in the address book
ElseIf Item.To = "efg@efg.com" Then
Exit Sub
Else
' #### USER OPTIONS ####
' address for Bcc -- must be SMTP address
' or resolvable to a name in the address book
strBcc = "email@email.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 to send the message?"
res = MsgBox(strMsg, vbYesNo + vbDefaultButton1, _
"Could Not Resolve Bcc")
If res = vbNo Then
Cancel = True
End If
End If
Set objRecip = Nothing
Exit Sub
End If
End Sub
I have signed the digital certificate for this macro, the problem is that same code in outlook 2013 only bcc part works. Can anyone suggest some adjustment for this code to work in 2013?
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
If Item.To = "abc@abc.com" Then
Exit Sub
' #### USER OPTIONS ####
' address for Bcc -- must be SMTP address
' or resolvable to a name in the address book
ElseIf Item.To = "efg@efg.com" Then
Exit Sub
Else
' #### USER OPTIONS ####
' address for Bcc -- must be SMTP address
' or resolvable to a name in the address book
strBcc = "email@email.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 to send the message?"
res = MsgBox(strMsg, vbYesNo + vbDefaultButton1, _
"Could Not Resolve Bcc")
If res = vbNo Then
Cancel = True
End If
End If
Set objRecip = Nothing
Exit Sub
End If
End Sub
I have signed the digital certificate for this macro, the problem is that same code in outlook 2013 only bcc part works. Can anyone suggest some adjustment for this code to work in 2013?