How can I make Outlook 2007 auto BCC messages to a specific email with specific words in subject using VBA?

tgadd picture tgadd · Apr 7, 2010 · Viewed 10.3k times · Source

Possible Duplicate:
Outlook VBA to BCC emails sent not working in Outlook 2007

So far I have this code from outlookcode.com which I can get to work sending all emails I send to the BCC email. I am not a developer, so I don't have a lot of context to go about editing this myself, or even approaching researching this. If anyone knows how to make this check for words in the subject, or check if the subject equals a certain string, I'd really appreciate it.

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 = "[email protected]"

    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

Answer

user1069275 picture user1069275 · Nov 28, 2011

If you don't want to get involved with VB, you could do this with the rules wizard as follows:

  1. Create one rule and make it your last rule. This rule should be applied when your name is in the To or Cc fields. And it should stop processing subsequent rules: Step 1: Select conditions: Where my name is in the To or Cc box. Step 2: Select actions: Stop processing more rules.
  2. Create another rule and add it to the bottom of rule create at step 1 above. Make it as follows: Step 1: Select conditions: Where my name is not in the To box. Step 2: do whatever you want with you BCC message here.

So, the thing with the procedure above is that if you reached the rule created on step 2 is because you received a message where your name is not in the To or Cc fields, i.e. you are in the Bcc field.

You just need those two rules because there is no such condition as "Where my name is NOT in the To or Cc box". But we can manage to do the same with the above workaround.