• Outlook User
  • New Outlook app
  • Outlook.com
  • Outlook Mac
  • Outlook & iCloud
  • Developer
  • Microsoft 365 Admin
    • Common Problems
    • Microsoft 365
    • Outlook BCM
    • Utilities & Addins

Macro to Move or Copy an Outlook message to another folder

Slipstick Systems

› Developer › Code Samples › Macro to Move or Copy an Outlook message to another folder

Last reviewed on May 16, 2018     34 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 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:

  1. Right click on Project1 and choose Insert > Module
  2. Copy and paste the macro into the new module.

More information as well as screenshots are at How to use the VBA Editor

Macro to Move or Copy an Outlook message to another folder was last modified: May 16th, 2018 by Diane Poremsky

Related Posts:

  • Macro to Create an Outlook Contact from an Email Message
  • Macro to automate the Move to Folder command
  • Moving Deleted Items
  • Move Outlook Folders using VBA

About 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.

Subscribe
Notify of
34 Comments
newest
oldest most voted
Inline Feedbacks
View all comments

Cyril (@guest_219940)
December 21, 2022 7:19 am
#219940

Hello
I'd like to move mails to severals folders after choosing the folders in a dialog box
Do you have a idea ?

0
0
Reply
Judd S. (@guest_217924)
April 15, 2021 5:10 pm
#217924

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

0
0
Reply
Naveen (@guest_217889)
April 12, 2021 10:18 am
#217889

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.

1
0
Reply
Naveen (@guest_217617)
February 23, 2021 2:34 pm
#217617

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

0
0
Reply
bugra (@guest_217418)
January 7, 2021 9:06 am
#217418

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 Sub

Last edited 3 years ago by Diane Poremsky
0
0
Reply
Shane V (@guest_215315)
June 1, 2020 8:40 pm
#215315

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

0
0
Reply
Diane Poremsky(@diane-poremsky)
Author
Reply to  Shane V
June 1, 2020 10:31 pm
#215316

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

0
0
Reply
Liviu (@guest_214616)
January 15, 2020 5:57 pm
#214616

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. )

0
0
Reply
Diane Poremsky(@diane-poremsky)
Author
Reply to  Liviu
January 16, 2020 1:01 am
#214617

I see Dmitry is answering the SO question - he's the expert on this stuff.

0
0
Reply
Javier (@guest_211849)
September 2, 2018 3:49 am
#211849

Thanks ¡ ¡¡ It´s a very hepuful and clear post.
Regards.
Javier

0
0
Reply

Visit Slipstick Forums.
What's New at Slipstick.com

Latest EMO: Vol. 30 Issue 16

Subscribe to Exchange Messaging Outlook






Support Services

Do you need help setting up Outlook, moving your email to a new computer, migrating or configuring Office 365, or just need some one-on-one assistance?

Our Sponsors

CompanionLink
ReliefJet
  • Popular
  • Latest
  • Week Month All
  • Use Classic Outlook, not New Outlook
  • How to Remove the Primary Account from Outlook
  • Disable "Always ask before opening" Dialog
  • Adjusting Outlook's Zoom Setting in Email
  • This operation has been cancelled due to restrictions
  • How to Hide or Delete Outlook's Default Folders
  • Reset the New Outlook Profile
  • Save Attachments to the Hard Drive
  • Add Attachments and Set Email Fields During a Mail Merge
  • Outlook SecureTemp Files Folder
  • Open Outlook Templates using PowerShell
  • Count and List Folders in Classic Outlook
  • Google Workspace and Outlook with POP Mail
  • Import EML Files into New Outlook
  • Opening PST files in New Outlook
  • New Outlook: Show To, CC, BCC in Replies
  • Insert Word Document into Email using VBA
  • Delete Empty Folders using PowerShell
  • Warn Before Deleting a Contact
  • Classic Outlook is NOT Going Away in 2026
Ajax spinner

Recent Bugs List

Microsoft keeps a running list of issues affecting recently released updates at Fixes or workarounds for recent issues in classic Outlook (Windows).

For new Outlook for Windows: Fixes or workarounds for recent issues in new Outlook for Windows .

Outlook for Mac Recent issues: Fixes or workarounds for recent issues in Outlook for Mac

Outlook.com Recent issues: Fixes or workarounds for recent issues on Outlook.com

Office Update History

Update history for supported Office versions is at Update history for Office

Outlook Suggestions and Feedback

Outlook Feedback covers Outlook as an email client, including Outlook Android, iOS, Mac, and Windows clients, as well as the browser extension (PWA) and Outlook on the web.

Outlook (new) Feedback. Use this for feedback and suggestions for Outlook (new).

Use Outlook.com Feedback for suggestions or feedback about Outlook.com accounts.

Other Microsoft 365 applications and services




New Outlook Articles

Open Outlook Templates using PowerShell

Count and List Folders in Classic Outlook

Google Workspace and Outlook with POP Mail

Import EML Files into New Outlook

Opening PST files in New Outlook

New Outlook: Show To, CC, BCC in Replies

Insert Word Document into Email using VBA

Delete Empty Folders using PowerShell

Warn Before Deleting a Contact

Classic Outlook is NOT Going Away in 2026

Newest Code Samples

Open Outlook Templates using PowerShell

Count and List Folders in Classic Outlook

Insert Word Document into Email using VBA

Warn Before Deleting a Contact

Use PowerShell to Delete Attachments

Remove RE:, FWD:, and Other Prefixes from Subject Line

Change the Mailing Address Using PowerShell

Categorize @Mentioned Messages

Send an Email When You Open Outlook

Delete Old Calendar Events using VBA

VBA Basics

How to use the VBA Editor

Work with open item or selected item

Working with All Items in a Folder or Selected Items

VBA and non-default Outlook Folders

Backup and save your Outlook VBA macros

Get text using Left, Right, Mid, Len, InStr

Using Arrays in Outlook macros

Use RegEx to extract message text

Paste clipboard contents

Windows Folder Picker

Custom Forms

Designing Microsoft Outlook Forms

Set a custom form as default

Developer Resources

Developer Resources

Developer Tools

VBOffice.net samples

SlovakTech.com

Outlook MVP David Lee

Repair PST

Convert an OST to PST

Repair damaged PST file

Repair large PST File

Remove password from PST

Merge Two Data Files

Sync & Share Outlook Data

  • Share Calendar & Contacts
  • Synchronize two computers
  • Sync Calendar and Contacts Using Outlook.com
  • Sync Outlook & Android Devices
  • Sync Google Calendar with Outlook
  • Access Folders in Other Users Mailboxes

Diane Poremsky [Outlook MVP]

Make a donation

Mail Tools

Sending and Retrieval Tools

Mass Mail Tools

Compose Tools

Duplicate Remover Tools

Mail Tools for Outlook

Online Services

Calendar Tools

Schedule Management

Calendar Printing Tools

Calendar Reminder Tools

Calendar Dates & Data

Time and Billing Tools

Meeting Productivity Tools

Duplicate Remover Tools

Productivity

Productivity Tools

Automatic Message Processing Tools

Special Function Automatic Processing Tools

Housekeeping and Message Management

Task Tools

Project and Business Management Tools

Choosing the Folder to Save a Sent Message In

Run Rules on messages after reading

Help & Suggestions

Submit Outlook Feature Requests

Slipstick Support Services

Buy Microsoft 365 Office Software and Services

Visit Slipstick Forums.

What's New at Slipstick.com

Home | Outlook User | Exchange Administrator | Office 365 | Outlook.com | Outlook Developer
Outlook for Mac | Common Problems | Utilities & Addins | Tutorials
Outlook & iCloud Issues | Outlook Apps
EMO Archives | About Slipstick | Slipstick Forums
Submit New or Updated Outlook and Exchange Server Utilities

Send comments using our Feedback page
Copyright © 2025 Slipstick Systems. All rights reserved.
Slipstick Systems is not affiliated with Microsoft Corporation.

wpDiscuz

Sign up for Exchange Messaging Outlook

Our weekly Outlook & Exchange newsletter (bi-weekly during the summer)






Please note: If you subscribed to Exchange Messaging Outlook before August 2019, please re-subscribe.

Never see this message again.

You are going to send email to

Move Comment