A user had this question:
I want to do the following:
- Copy a message from one public folder to another public folder
- Mark the original message as read
- Mark the original Complete
- Add a Category to itA 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 objDestFolder As Outlook.MAPIFolder Dim objItem As Outlook.MailItem Dim objCopy As Outlook.MailItem Set objNS = Application.GetNamespace("MAPI") ' Set the destination folders Set objDestFolder = objNS.Folders("Public Folders - firstname.lastname@example.org") _ .Folders("All Public Folders").Folders("Old") ' move to a subfolder of the Inbox Set objDestFolder = objNS.GetDefaultFolder(olFolderInbox).Folders("Subfolder") Set objItem = Application.ActiveExplorer.Selection.Item(1) ' copy and move first Set objCopy = objItem.Copy objCopy.Move objDestFolder ' to move ' objItem.Move objDestFolder ' then do whatever With objItem .UnRead = False .MarkAsTask olMarkComplete .Categories = "This Category" .Save End With Set objDestFolder = Nothing Set objNS = Nothing End Sub
Move Opened Message
With a few tweaks, you can move an opened message to a folder. In this example, I'm moving the opened message to a subfolder of the Inbox.
To use this macro, create a macro button on the ribbon or quick access toolbar in an opened message. Then click the button to run the macro.
Sub MoveOpenMessage() Dim objNS As Outlook.NameSpace Dim objDestFolder As Outlook.MAPIFolder Dim objItem As Outlook.MailItem Set objNS = Application.GetNamespace("MAPI") ' Set the destination folder ' move to subfolder of inbox Set objDestFolder = objNS.GetDefaultFolder(olFolderInbox).Folders("Subfolder") ' use selected message ' Set objItem = Application.ActiveExplorer.Selection.Item(1) ' use opened message Set objItem = Application.ActiveInspector.CurrentItem ' then do whatever With objItem .UnRead = False .MarkAsTask olMarkComplete .Categories = "This Category" .Save End With ' to move objItem.Move objDestFolder Set objDestFolder = Nothing Set objNS = Nothing End Sub
How to use the macros on this page
First: You need to have macro security set to the lowest setting, Enable all macros during testing. The macros will not work with the top two options that disable all macros or unsigned macros. You could choose the option Notification for all macros, then accept it each time you restart Outlook, however, because it's somewhat hard to sneak macros into Outlook (unlike in Word and Excel), allowing all macros is safe, especially during the testing phase. You can sign the macro when it is finished and change the macro security to notify.
To check your macro security in Outlook 2010 and newer, go to File, Options, Trust Center and open Trust Center Settings, and change the Macro Settings. In Outlook 2007 and older, look at Tools, Macro Security.
After you test the macro and see that it works, you can either leave macro security set to low or sign the macro.
The macros on this page should be placed in a module.
Open the VBA Editor by pressing Alt+F11 on your keyboard.
To put the code in a module:
- Right click on Project1 and choose Insert > Module
- Copy and paste the macro into the new module.
More information as well as screenshots are at How to use the VBA Editor