Outlook Macro : Move to Specified Folder & Mark As Read

Tuesday, April 22 2008 @ 12:54 PM CDT

Contributed by: Yeraze

As a victim of Microsoft Outlook, I hear alot about using it in the GTD philosophy.  One of my favorite websites, LifeHacker, extolls it's virtues (GTD, not Outlook) on a daily basis.  Yesterday they posted an article about how to modify your toolbars to give you shortcut keys for "Copy to folder" and "Move to folder" actions.  I don't know why I never thought of that before.

I quickly set that up, and then realized I could add an additional shortcut for "Mark as Read" (our IT staff has disabled the ability to Mark as Read when Previews).  With those in place, I decided I might actually try another GTD point: an empty inbox.  The key to an empty inbox is to have a place to dump mail you've read and responded to, but don't really need anymore except for reference.  They call it an "Archived" or "Processed" folder.  While I could do this with the "Move to" shortcut, I had to select the folder everytime.  With a bit of googling, I was able to setup an Outlook VB Macro (Under the Tools Menu) to Mark the message as read and move it to my personal PST file, in a folder called "Ancient Archive".

For everyone else's benefit, the VB code is as follows:

Sub MoveToArchive()
On Error Resume Next
    Dim objFolder As Outlook.MAPIFolder
    Dim objNS As Outlook.NameSpace, objItem As Outlook.MailItem

    Set objNS = Application.GetNamespace("MAPI")
    Set objFolder = objNS.Folders("Personal Folders").Folders("Ancient Archive")
'Assume this is a mail folder
 
 
    If objFolder Is Nothing Then
        MsgBox "This folder doesn't exist!", vbOKOnly + vbExclamation, "INVALID FOLDER"
    End If
 
 
    If Application.ActiveExplorer.Selection.Count = 0 Then
        'Require that this procedure be called only when a message is selected
        Exit Sub
    End If
 
    For Each objItem In Application.ActiveExplorer.Selection
        If objFolder.DefaultItemType = olMailItem Then
            If objItem.Class = olMail Then
                objItem.UnRead = False
                objItem.Move objFolder
            End If
        End If
    Next
 
    Set objItem = Nothing
    Set objFolder = Nothing
    Set objNS = Nothing
End Sub

Technorati Tags: , , ,

Comments (0)


Yeraze's Domain
http://www.yeraze.com/article.php/outlook_macro_move_to_folder_mark_Read