MS Outlook 2003 rule or script to move all outgoing email with me at BCC to a certain folder

Posted on 2011-04-26
Last Modified: 2012-06-22
Question by:easycapital
    LVL 76

    Accepted Solution

    Hi, easycapital.

    This should do it.  This script monitors items as they are sent and sets them to be saved in a certain folder if your email address is on the BCC line.  Follow these instructions to add the code to Outlook.

    1.  Start Outlook
    2.  Click Tools > Macro > Visual Basic Editor
    3.  If not already expanded, expand Microsoft Office Outlook Objects and click on ThisOutlookSession
    4.  Copy the code from the Code Snippet box and paste it into the right-hand pane of
    5.  Outlook's VB Editor window
    6.  Edit the code as needed.  I included comment lines wherever something needs to or can change
    7.  Click the diskette icon on the toolbar to save the changes
    8.  Close the VB Editor
    9.  Click Tools > Macro > Security
    10. Set the Security Level to Medium
    11. Close Outlook
    12. Start Outlook
    13. Outlook will display a dialog-box warning that ThisOutlookSession contains macros and asking if you want to allow them to run.  Say yes.

    In case you aren't familiar with folder paths in Outlook:

    A folder path in Outlook is essentially the same as a folder path in the file system.  The one difference being that Outlook folder paths do not include a drive letter.  The path to a folder is a list of all the folders from the root to the target folder with each folder name separated from the preceding folder name by a backslash (i.e. \).  Consider the following folder structure:

    Mailbox - Doe, John
        - Calendar
        - Inbox
        - Tasks
    Personal Folders
        + Marketing
            + Proposals
            + Reviews
        + Projects
            + Project 1
            + Project 2

    The path to "Inbox" is "Mailbox - Doe, John\Inbox".
    The path to "Reviews" is "Personal Folders\Marketing\Reviews".
    The path to "Project 1" is "Personal Folders\Projects\Project 1".
    Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
        'On the next line edit the path to the folder you want to save the BCC items to'
        Const BCC_FOLDER_PATH = "Mailbox\Folder\Folder"
        Dim olkRcp As Outlook.Recipient
        If Item.Class = olMail Then
            For Each olkRcp In Item.Recipients
                If (olkRcp.Address = Session.CurrentUser.Address) And (olkRcp.Type = olBCC) Then
                    Item.SaveSentMessageFolder = OpenOutlookFolder(BCC_FOLDER_PATH)
                    Exit For
                End If
        End If
    End Sub
    Function OpenOutlookFolder(strFolderPath As String) As Outlook.MAPIFolder
        ' Purpose: Opens an Outlook folder from a folder path.'
        ' Written: 4/24/2009'
        ' Author:  BlueDevilFan'
        ' Outlook: All versions'
        Dim arrFolders As Variant, _
            varFolder As Variant, _
            bolBeyondRoot As Boolean
        On Error Resume Next
        If strFolderPath = "" Then
            Set OpenOutlookFolder = Nothing
            Do While Left(strFolderPath, 1) = "\"
                strFolderPath = Right(strFolderPath, Len(strFolderPath) - 1)
            arrFolders = Split(strFolderPath, "\")
            For Each varFolder In arrFolders
                Select Case bolBeyondRoot
                    Case False
                        Set OpenOutlookFolder = Outlook.Session.Folders(varFolder)
                        bolBeyondRoot = True
                    Case True
                        Set OpenOutlookFolder = OpenOutlookFolder.Folders(varFolder)
                End Select
                If Err.Number <> 0 Then
                    Set OpenOutlookFolder = Nothing
                    Exit For
                End If
        End If
        On Error GoTo 0
    End Function

    Open in new window

    LVL 13

    Expert Comment

    by:Chris Raisin
    Very nice, BlueDevilFan

    LVL 76

    Expert Comment

    by:David Lee
    Thanks, Chris!

    Author Closing Comment

    Real Nice!

    LVL 76

    Expert Comment

    by:David Lee
    You're welcome, JP.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    Granting full access permission allows users to access mailboxes present in their database. By giving full access permission one can open and read the content of any mailbox but cannot send emails from that mailbox.
    Create high volume marketing opportunities using email signatures with these top 10 DOs and DON'Ts of email signature marketing.
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now