First, this is not something I created, but that I have found very useful. Credit goes to the original author at ‘Chewy’s Blog‘.
But before you go running off and create a macro with this in Outlook, I have a few caveats for you:
- When you use a macro made from this code to move a message, it changes the timestamp on the message to the time you move it. If you need to see the actual time a message was sent or received, you have to open the message and look at the sent/received time there.
- This moves the selected message, not necessarily the message you have open in the foreground. This is and important distinction, and I’ll give you a scenario. Let’s say you create a button for the macro using this code, and you put the button in the quick access toolbar which shows up in your actual message window. You might assume that if you click the button for this macro in the message window, that it moves the message you are looking at to your specified folder. And it might, if that happens to be the message that is selected in Outlook. However, if you open a message window and have it open for a while and go back to Outlook and you have selected a different message, when you come back and click the macro button, it will move the message you have selected in Outlook. Then, if you click the button and the message doesn’t go away you might think you missed it and keep clicking. This will keep moving messages in your inbox to the specified folder and you might not even see it happening if Outlook is behind the message you are looking at. So, be careful. Don’t put a button for this macro in your message (quick access) menu.
A few instructions:
- Go to Tools –> Macro –> Macros… to create it.
- Name the Macro “MoveSelectedMessagesToFolder”
- Delete what shows up in the macro window by default and copy/paste the following code in the window
- Replace the folder name which is “_Reviewed” in this example, to whatever folder to which you want to move messages
- Create a toolbar button for the macro (http://blogs.technet.com/kclemson/pages/87358.aspx)
And here is the code:
On Error Resume Next
Dim objFolder As Outlook.MAPIFolder, objInbox As Outlook.MAPIFolder
Dim objNS As Outlook.NameSpace, objItem As Outlook.MailItem
Set objNS = Application.GetNamespace(“MAPI”)
Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
Set objFolder = objInbox.Folders(“_Reviewed”)
‘Assume this is a mail folder
If objFolder Is Nothing Then
MsgBox “This folder doesn’t exist!”, vbOKOnly + vbExclamation, “INVALID FOLDER”
If Application.ActiveExplorer.Selection.Count = 0 Then
‘Require that this procedure be called only when a message is selected
For Each objItem In Application.ActiveExplorer.Selection
If objFolder.DefaultItemType = olMailItem Then
If objItem.Class = olMail Then
Set objItem = Nothing
Set objFolder = Nothing
Set objInbox = Nothing
Set objNS = Nothing