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 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 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 - alias@domain.com") _
.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
Move messages using Folder Picker
If you want to pick the folder to move to you need to use the PickFolder function. However it won't allow you to set a default parent folder. If you want to set a default parent folder, you need to use Redemption.

The first sample below uses Outlook's native PickFolder function.
These macros work on the selected message.
Sub MoveMessagePicker()
Dim objNS As Outlook.NameSpace
Dim objDestFolder As Outlook.MAPIFolder
Dim objItem As Outlook.MailItem
Set objNS = Application.GetNamespace("MAPI")
' Pick the destination folders
Set objDestFolder = objNS.PickFolder
If Not (objDestFolder Is Nothing) Then
Set objItem = Application.ActiveExplorer.Selection.Item(1)
objItem.Move objDestFolder
End If
Set objDestFolder = Nothing
Set objNS = Nothing
End Sub
This version of the macro uses Redemption and allows you to set the parent folder. As shown in the screenshot below, I'm displaying only the folders in the designated path. To show all folders in the data file, change False to True in this line:
dlg.ShowParentFolders = False

Sub MoveMessagePathRDO()
' requires Redemption
' http://dimastr.com/redemption/download.htm
Dim Session As Object
Dim parentFolder 'As Redemption.RDOFolder
Dim rFolder 'As Redemption.RDOFolder
Dim objDestFolder As Outlook.MAPIFolder
Dim objItem As Outlook.MailItem
Set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
Set dlg = Session.GetSelectFoldersDialog
dlg.SelectedFolder = Session.GetDefaultFolder(olFolderInbox).Folders("My Folder")
' to show only the parent and subfolders
dlg.ShowParentFolders = False
If dlg.Display Then
Set rFolder = dlg.SelectedFolder
End If
If Not (rFolder Is Nothing) Then
'convert Redemption.RDOFolder back to Outlook.Folder
Set objDestFolder = Application.Session.GetFolderFromID(rFolder.EntryID)
End If
If Not (objDestFolder Is Nothing) Then
Set objItem = Application.ActiveExplorer.Selection.Item(1)
objItem.Move objDestFolder
End If
Set objDestFolder = 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
Cyril says
Hello
I'd like to move mails to severals folders after choosing the folders in a dialog box
Do you have a idea ?
Judd S. says
Hi I am trying to use a modified version of the move copy and move to my archive from a specific folder. I am erroring out at the bolded line. The error is Outlook object variable or with block variable not set. I think it has to do with the objItem?
[Code]
Sub MoveDraftMail()
Dim objOutlook As Outlook.Application
Dim objNamespace As Outlook.NameSpace
Dim objSourceFolder As Outlook.MAPIFolder
Dim objDestFolder As Outlook.MAPIFolder
Dim objItem As MailItem
Dim Archive_Folder As Outlook.MAPIFolder
Set objOutlook = New Outlook.Application
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objSourceFolder = objNamespace.Folders(10).Folders("HouseBillofLadingReport")
Set Archive_Folder = objNamespace.Folders("Online Archive - My@email").Folders("Personal_Folders").Folders("2021").Folders("InBox")
ObjItem.Move Archive_Folder
Set objDestFolder = Nothing
End Sub
[Code\]
Any suggestions.
Thank you
Naveen says
Hi Diane
Would be great if you could help me out. I have a generic mail box accounts.payable@xyz.com where we receive emails from vendors. my team goes into the inbox and checks emails that were sent to accounts.payable@xyz.com and copied to another contact in our organization. If the email is just sent to accounts.payable@xyz.com then team forwards it to the concerned contact and if the email has accounts.payable@xyz.com and the contact of our organization then the team deletes the email. I am looking for a macro that will check if there is accounts.payable@xyz.com in the to or cc and also if there is another contact from our organization, if yes then delete and if the email contains just accounts.payable@xyz.com email without anyone else n our organization then leave it in inbox. I tried rules but it only takes either or Or. Do you think we can achieve this task through a macro? I am not sure if I did a good job explaining my requirement :) hoping I did, really appreciate your help Diane.
Naveen says
Hi Diane,
I need help :)
We have a accounts.payable mail box and we get numerous emails in it. I wanted to know if can create a macro to move emails that contains accounts.payable email in To or CC among others then I want to move them to deleted folder. Our practice is to delete emails that have the staff from departments on an email and accounts payable is copied on it. for example: if I get an email in accounts.payable inbox where, accounts payable is copied in cc or in to: and other staff in my organization is copied on it, I want to delete it. I am not sure if I make sense. :) but any help would be very helpful. It will save my team great deal of manual work to go to each email and delete them or to action them.
thank you Diane
Naveen
bugra says
Hi, I'm trying to combine two macros to move emails to searched and found folders. In first part I'm searching a folder (for example *jobsite*) and the macro shows the path and -if I choose to- activates the folder. I found this macro on VBoffice_dot_net and it works perfectly.
Now what I want is to move the selected email to this particular folder. I tried to tweak the code above, but somohow, I can't bring the code to move the copied email.
Sub MoveMessageNew() 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 objItem = Application.ActiveExplorer.Selection.Item(1) 'I'm calling here the Findfolder macro, m_Folder and m_Folder2 are the variables I used in this macro. They are defined as Outlook.MAPIFolder Call FindFolder ' copy and move Set objCopy = objItem.Copy objItem.Move (m_Folder2) objCopy.Move m_Folder2 'Above I'm trying both cases, none of them work. on the watch window I see the variable has the correct folder in it. ' to move ' objItem.Move objDestFolder Set objDestFolder = Nothing Set objNS = Nothing End SubShane V says
Hi, I am using the MoveCopyMessage module to move to a subfolder called "Subfloder", however I would like to move it to a subfolder of another mailbox. Is this possible? The other mailbox is an account in my outlook. SHANE
Diane Poremsky says
As long as the mailbox/folder is in your profile you can move to it. Use one of the methods in this article to get the mailbox - use the getfolderpath method if its an account in the profile and the shared mailbox method if its in a shared mailbox.
https://www.slipstick.com/developer/working-vba-nondefault-outlook-folders/#GetFolderPath
Liviu says
Just noticed that doing a simple MailItem.Move leaves a copy behind in the Recoverable Items folder of the Exchange mailbox. The VBA code is similar to the above, and all it does is move a mail item from the inbox to another (non-default) folder within the same mailbox. The move operation itself works, but I am puzzled that it would also save a copy under Recoverable Items. Moving the same mail item manually in Outlook leaves no such copy behind.
The behavior hints at a hidden copy being made then soft-deleted by MailItem.Move along the way, which is both unnecessary and wasteful. I wonder if/how a "clean" move could be duplicated in VBA code to work like it does in Outlook itself, without the overhead of an extra copy.
My environment is the desktop Outlook 365 running against a (business) office.com account, in case that matters, with the Exchange mailbox being the only account set up in Outlook. Thank you for any insights.
( FWIW I cross-posted the same question on SO here. )
Diane Poremsky says
I see Dmitry is answering the SO question - he's the expert on this stuff.
Javier says
Thanks ¡ ¡¡ It´s a very hepuful and clear post.
Regards.
Javier
Reuben Dayal says
Hi again Diane,
I have found solutions for both the below issues.
However, I am unable to figure out one this. When the folder picker is fired up. It selects my default email account's inbox. However, I work with two separate email accounts and all my work is filed in the other email account. So I need to each time navigate all the way up in the folder picker window and then select the appropriate folder. How do I make the folder picker always open a specific folder as I would always file these emails under that folder's subfolders.
Thank you again.
Reuben Dayal says
Hi Diane,
I have used your wonderful code + the folder picker option and it works great!
I have a few questions though:
1) Change the Application.ActiveExplorer.Selection to the folder where I moved the message to?
2) How to copy the "Name" of the folder I created, and call/pass that as a variable to another Sub. As I am also doubling this macro with your other wonderful macro for saving messages and attachments, and creating a new folder on my network drive by that "Name". This will prevent me from doing this naming step twice.
Thank you so much.
Richard says
Dear Diane,
Is it possible to copy the current mailitem (I currently have open and am looking at it) to the Clipboard. Many times I wish to paste this into a new email, but then I need to find where the email is located, copy it and then paste it into a new email which is very time consuming.
Please note I already have a different email with text in it. So I need to copy the .msg to the clipboard, the full mail item.
Is this possible?
Kind regards,
Richard
Diane Poremsky says
Do you want it as an attachment or just the message body? You can do either... either manually or using a macro. You should be able to bring the outlook window (don't click on folders or messages - click on the frame so the selection doesn't move) into focus and press Ctrl+C to copy it as an attachment. Of course, coping the body is easy- select and Ctrl+C.
If you do either a lot, you can use a macro to save a step or two.
Diane Poremsky says
>> Please note I already have a different email with text in it. So I need to copy the .msg to the clipboard, the full mail item.
If this means you already moved the mouse off the message, the method i mentioned won't work to copy as an attachment. I think you'll need to use a macro.
Richard says
Hi again, I had lost the link to this posting but found it again, luckely.
The message I am looking at is opened, so I cannot see in the mailbox where it is. I would need to copy the .msg to the clipboard. I assumed I would need to use a macro and I have already tried many things adjusting current code, but I cannot get it to work. I have searched a lot on different sites but haven't found a code which exactly does this. So I would really appreciate it if you would provide me with this code, hoping it is possible to do this.
Kind Regards,
Richard
Diane Poremsky says
so you want to copy the opened message as an msg file? (not just the message body)
Richard says
That is correct.
Diane Poremsky says
Are you moving it to a new folder or need it copied for another use? I added a macro version that moves the open message to a folder at this end of this article... i don't think outlook vba can copy objects to the clipboard.
Richard says
Thank you, I see the code you provided. This is however to copy the message to a different folder. You wrote: "i don't think outlook vba can copy objects to the clipboard."
So I assume something like this will not be possible?
Set objItem = Application.ActiveInspector.CurrentItemWith objItem
.Save
End With
objItem.CopyToClipboard
Thank you for looking at it anyways.
Kind regards,
Richard
Diane Poremsky says
No, outlook doesn't use that - you need to use MSForms.DataObject, which only handles text in vba.
https://www.slipstick.com/developer/code-samples/paste-clipboard-contents-vba/
To put an object on the clipboard, you would need to hack the private clipboard format used by Outlook when an item is copied to the clipboard - code sample: https://github.com/yasoonOfficial/outlook-dndprotocol -
Richard says
Thank you, I will have a look at it.
Kind regards,
Richard
Varun says
Hi, this is just perfect, but i am getting a permission issue stating that i dont have access to delete the mail from the public folder. Is there a copy paste command instead of the move command?
Diane Poremsky says
No there isn't. Copy is copy in place and move. It should work to save to the hard drive then add it to the new outlook folder.
https://www.slipstick.com/developer/code-samples/move-messages-file-system-outlook/
Paul Couch says
Hello Diane,
I am interested in using this macro to monitor for new messages in GMail Folder 1 and automatically either copy or move them to GMail Folder 2. I wouldn't need it to do anything else. What would be the syntax for IMAP GMail folders under Outlook 2010? (I assume I would need to make the appropriate substitutions in the 'source and destination folders' section of code)
Also, since my client machine is always on with Outlook 2010 open, would this macro run on its own like a rule does, or is a macro something that has to be manually run? Thanks very much for all that you do!
Paul
Diane Poremsky says
it's the same for any account - if its the default folders you use the builtin GetDefaultFolders, if its in a different data file you need to use a vba function. More info here - https://www.slipstick.com/developer/working-vba-nondefault-outlook-folders/
Sarah says
How can I use this for non-public folders in a shared inbox?
Diane Poremsky says
The folder needs to be viisible in your profile to copy to it - use the shared mailbox method at https://www.slipstick.com/developer/working-vba-nondefault-outlook-folders/ to identify the shared mailbox. You'll set the folder using .folders("foldername")
Rolf says
Unfortunately this does not work for accounts in exchange activesync, e.g. hotmail/outlook.com.
What I will try next is to mark the item in some way that allows a manually triggered rule to do the copy to another folder. I will report back as to how that went.
Diane Poremsky says
Correct, you can't move messages in EAS accounts... but the good news is that outlook.com is moving to Office 365 hosting. Once your account is moved, remove it from outlook and add it back using auto account setup. Then it will work.
Ralph says
Hello Diane,
I need to move 300 folders with the emails they have inside to other email address. I mean, I have a MS EX account and an IMAP account. MS EX account has more than 500 folders (and emails into them) into the Inbox folder, I need to move all of them into the IMAP account Inbox folder. I couldn't import because all the times that I did shows error of importing.
How do I need to do that? Does Folder.CopyTo method work for this topic?
Diane Poremsky says
it *should* work, but if the folders have a a lot of mail, it would be better to move/copy the folders slower. My preference would be to export to a pst, then Move (not copy) the folders one at a time and frequently verify they uploaded by checking the account online. Yes, it's slow, but if something causes the sync to stop, you know which folder is the problem and you know which folders were moved.
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 Poremsky says
you want a macro to open a folder? use something like
Set objApp.ActiveExplorer.CurrentFolder =objdestFolder