I have assigned contacts in my outlook to various categories. So I want to create a rule such that if I send an email to any contact in one of the category, the email is Bcc'ed to an email address.
Here's the code I currently have and I keep getting the error 438 for line Set oContact = oRecip.GetContact
Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim oContact As Outlook.ContactItem
Dim oRecip
Dim Recip As Recipient
Dim BccRecip As String
Dim strCategoryName As String
Set oRecipients = Item.Recipients
Set oRecipient = Recipients(1)
Set oContact = oRecipient.GetContact
strCategoryName = oContact.Categories
strCategoryName = oContact.Categories
If InStr(LCase(strCategoryName), "test") > 0 Then
BccRecip = "abc@def.com"
Else
Exit Sub
End If
Set Recip = Item.Recipients.Add(BccRecip)
Recip.Type = olBCC
If Recip.Resolve Then
Cancel = False
Else
Cancel = True
End If
End Sub
Thanks in advance for your help.