Wednesday, February 25, 2009

Auto BCC in Outlook 2007

Recently I decided to combine my Internet Email with my office Microsoft Exchange Email. This work beautifully except now I lost the features of auto bcc all email I sent out to my GMail account. This is available in Thunderbird not not available in Outlook 2007. I wish Microsoft can have this in the Rules. Anyhow below is how I setup my Multi Account some VBA to perform the Auto BCC.

In Outlook 2007. Click Tools –> Settings the use the wizard to add a new Account. For better management I create a new pst (Outlook Data File) to store email for this particular account. Just click Change Folder button to assign all email from the second account to this pst file. IMO cleaner and neater.

After you had setup the second email account and tested working correctly it’s time to add in the VBA Code to auto BCC. You may refer to this link on how to do it. Based on the sample code I did some changes to only bcc my email for specific account. Below is the modified version.

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.SendUsingAccount = "<Outlook EMail Account Setting Name>" Then
strBcc = "someone@example.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 If
End Sub

To get rid of the Security message you need to sign the code using personal certificate. Refer to this link.

Lastly you may asked why I need to bcc my email. Well I used gmail to backup my company email so in order to maintain a full correspondence record all email reply on my PC (aka Outlook 2007) need to stored a copy in gmail.

No comments: