Outlook Macro to BCC Specific Sent E-Mails to Party

So I know in Outlook you can set a macro to automatically BCC messages to someone else by using:

Public Sub MyMacro()
Dim Mail as Outlook.MailItem

Set Mail=Application.ActiveInspector.CurrentItem
Mail.BCC = "your address here"
End sub

But what I would like to know if it is possible to set condition. For example, so that only messages with specific words in the subject or that are sent to a specific recipient are BCC'd.
LVL 2
RTM2007Asked:
Who is Participating?
 
David LeeCommented:
"Which command makes it not show up in the sent items?"
Do you mean you want the message to not show up in sent items at all?

"For example if I only want e-mails that are sent to jmallow@contingentco1.com BCC'd?"
The code below will do this.  If you are using Outlook 2003 or earlier, then this is going to trigger Outlook's built-in security.
Public Sub MyMacro()
    Dim Mail as Outlook.MailItem, olkRecipient as Outlook.Recipient
    Set Mail=Application.ActiveInspector.CurrentItem
    If InStr(1, Mail.Subject, "Some word or phrase") Then
        Mail.BCC = "your address here"
    End If
    For Each olkRecipient in Mail.Recipients
        If olkRecipient.Address = "jmallow@contingentco1.com" Then
            Mail.BCC = "your address here"
        End If
    Next
End sub

Open in new window

0
 
RTM2007Author Commented:
Also is it possible to have it not show up as it was sent to that BCC recipient in the Sent Items message?
0
 
David LeeCommented:
Hi, RTM2007.

Yes, it's possible to have the BCC work off of a condition.  It's not possible to to hide the fact that the message was BCC'd in Sent Items.
Public Sub MyMacro()
    Dim Mail as Outlook.MailItem
    Set Mail=Application.ActiveInspector.CurrentItem
    If InStr(1, Mail.Subject, "Some word or phrase") Then
        Mail.BCC = "your address here"
    End If
End sub

Open in new window

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
RTM2007Author Commented:
Which command makes it not show up in the sent items?

Also how do you set the condition for if instr so that if it sent to someone.. For example if I only want e-mails that are sent to jmallow@contingentco1.com BCC'd?
0
 
RTM2007Author Commented:
Will it trigger security for Outlook 2007? How do I disable the security for 2003?
0
 
Chris BottomleySoftware Quality Lead EngineerCommented:
In regard to suppressing teh security warnings:

You can modify your code to use redemption:
    http://www.dimastr.com/redemption/ 
You can use an outlook add-in i.e:
    http://www.mapilab.com/outlook/security 
Or finally you can use clickyes
    http://www.contextmagic.com/

Chris
0
 
David LeeCommented:
No, it will not trigger the security warning for Outlook 2007.  

Outlook security cannot be turned off or disabled,  Instead you have to work around it using one of the tools that Chris listed.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.