Macro to Copy an Outlook message to another folder

Last reviewed on April 5, 2014   —  2 comments

A user had this question:

I want to do the following:
1. Copy a message from one public folder to another public folder
2. Mark the original message as read
3. Mark the original Complete
4. Add a Category to it

A Quick Step will categorize the e-mail first (it has a higher priority) and both the actual e-mail and the copied one will be 'flagged' with the category. Only the original message should be marked as read and categorized.

While you can't use a quick step, you can use a macro to replicate the steps. The following macro will do everything the quick step did, but you can control the order the steps are completed when you use a macro.

Any fields you want to change on both the original and the copy are done before the Move, any changes that apply to only the original message are done after the copy is moved.

Sub MoveCopyMessage()
 
    Dim objNS As Outlook.NameSpace
    Dim objSourceFolder As Outlook.MAPIFolder
    Dim objDestFolder As Outlook.MAPIFolder
    Dim objItem As Outlook.MailItem
    Dim objCopy As Outlook.MailItem
    
    Set objNS = Application.GetNamespace("MAPI")

' Set the source and destination folders   
    Set objSourceFolder = objNS.Folders("Public Folders - alias@domain.com") _
         .Folders("All Public Folders").Folders("New")
    Set objDestFolder = objNS.Folders("Public Folders - alias@domain.com") _
         .Folders("All Public Folders").Folders("Old")
 
    Set objItem = Application.ActiveExplorer.Selection.Item(1)
        
 ' copy and move first 
     Set objCopy = objItem.Copy
      objCopy.Move objDestFolder
        
' then do whatever
        With objItem
            .UnRead = False
            .MarkAsTask olMarkComplete
            .Categories = "This Category"
            .Save
        End With
        
    Set objSourceFolder = Nothing
    Set objDestFolder = Nothing
    Set objNS = Nothing
End Sub

About Diane Poremsky

Diane Poremsky
A Microsoft Outlook Most Valuable Professional (MVP) since 1999, Diane is the author of several books, including Outlook 2013 Absolute Beginners Book. She also created video training CDs and online training classes for Microsoft Outlook. You can find her helping people online in Outlook Forums as well as in the Microsoft Answers and TechNet forums.

Please post long or more complicated questions at Outlook forums by Slipstick.com.

2 responses to “Macro to Copy an Outlook message to another folder”

  1. Ron Beugeling

    Hello Diane,

    Thank you for sharing this macro.
    However, I do have a few questions.

    Is it possible to leave the source folder open en just move a selected email to a specific public folder from a personal Inbox or Sent items?

    Where can I find the exact name of the Public Folder to put in the syntax where the destination folder is set.

    Kind regards,

    Ron Beugeling

Leave a Reply

If the Post Comment button disappears, press your Tab key.

This site uses XenWord.