Pages

Saturday, September 22, 2012

Microsoft Office OutLook 2007- Automatic BCC to another mail account for all outgoing mails

Have you ever wanted to automatically BCC all your outbound mail to a specific email address? In my case, one of my colleague wanted to send a copy of ALL sent mail from Outlook at work to Gmail  You could try to do this via Outlook's Rules and Alerts, but there's no option to BCC...only cc. Did not prefer that all work contacts not know the personal Gmail address, and it's not very professional. Also don't want to manually enter the Gmail address in the BCC field of every outgoing message. Found a solution through Visual Basic Scripting.

First you have to check your Outlook allow to run Macros. If not, do the steps to run Macros.

  1. From the menu bar, select Tools->Trust Centre
  2. In the Trust Centre's left navigation menu, click on Macro Security
  3. Select either Warnings for all macros or No security checks for macros (the first option requires you to enable macros every time Outlook starts, the second option enables macros automatically).
Now you can write VBA code in Outlook.  Steps to write code in Outlook 2007

  1. Open MS Outlook 2007
  2. Under the Tools menu, select Macro > Visual Basic Editor (or Alt+F11)
  3. In the left menu bar, expand Project1, Microsoft Outlook Session, and open ThisOutlookSession
  4. Enter copy & paste this code, making sure to substitute someone@domain.com with your real Gmail address and "Outlook EMail Account " with your Outlook Account Email Address
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" 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

No comments:

Post a Comment