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

Comments

  1. Ron Beugeling says

    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

    • Diane PoremskyDiane Poremsky says

      you want a macro to open a folder? use something like
      Set objApp.ActiveExplorer.CurrentFolder =objdestFolder

Leave a Reply