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

Thanks,
JP
easycapitalAsked:
Who is Participating?
 
David LeeCommented:
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)
                Item.Save
                Exit For
            End If
        Next
    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
    Else
        Do While Left(strFolderPath, 1) = "\"
            strFolderPath = Right(strFolderPath, Len(strFolderPath) - 1)
        Loop
        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
        Next
    End If
    On Error GoTo 0
End Function

Open in new window

0
 
Chris Raisin(Retired Analyst/Programmer)Commented:
Very nice, BlueDevilFan

Cheers
Chris
0
 
David LeeCommented:
Thanks, Chris!
0
 
easycapitalAuthor Commented:
Real Nice!

Thanks,
JP
0
 
David LeeCommented:
You're welcome, JP.
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.