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

Use a macro to move Sent Items

Slipstick Systems

› Developer › Code Samples › Use a macro to move Sent Items

Last reviewed on November 2, 2021     47 Comments

I hear from a lot of users who don't like how Outlook handles sent items with an IMAP account. In older versions of Outlook, IMAP sent items use the local Sent Items folder. While Outlook 2007 and 2010 can be configured to use the IMAP sent folder, when you use a Send by email command in other applications, the sent item goes into the local data file, ignoring the account configuration. Outlook 2013 uses XLIST from the IMAP server to determine the sent items folder, but if the IMAP server doesn't support XLIST, the sent item might be saved locally. Outlook 2016 and newer handles it better, using the folder the server uses or one named Sent Items.

For Exchange users, Sent Items are stored in the account's mailbox (and have an option use the option to Save sent items with the original, if not in the Inbox). But Shared mailboxes save a copy in the users own Sent Items folder by default, but the shared mailbox may be configured save a copy in the shared mailbox sent folder too.

You can solve this problem by monitoring the Sent Items folder and moving sent messages to the desired folder.

Outlook 2013 users who want to move IMAP messages to a local pst file can use this macro too, however, it will not move the messages immediately. They need to sync down from the IMAP server first.

To use the macros on this page, you need to use the GetFolderPath macro from GetFolderPath.

You'll also need to set macro security to low to test the macro.

Press Alt+F11 to open the VBA editor. Expand Project1 and Microsoft Outlook Objects then double click on ThisOutlookSession. Paste the code into ThisOutlookSession. GetFolderPath can be pasted below this macro or in a new module.

To use this with multiple accounts, copy the IF... End IF block and change the account name and folder path for each account.

The account name and the data file name are usually the same - in Outlook 2010 and newer, both are the email address by default.

You need to use the account name as seen in File, Account Settings (or in the From field if you have multiple accounts) and the data file name (and path to the Sent folder) as seen in the folder list.
Account and file names in Outlook

You can get the path to the sent folder from folder properties. Right click on the sent folder, choose Properties. Select the path from the Location field (without the \\) and the folder name from the name field.
properties dialog

Note: this macro will work with any account type.

These macros start when Outlook starts. To test it without restarting Outlook, click in the Application_Startup macro and click the Run button (or press F5).

Only move Sent mail from one account

This macro checks the sender address and only moves mail sent from that address.

Private WithEvents Items As Outlook.Items
 
Private Sub Application_Startup()
    Set Items = Session.GetDefaultFolder(olFolderSentMail).Items
End Sub

Private Sub Items_ItemAdd(ByVal Item As Object)

If Item.SendUsingAccount = "alias@domain.com" Then
' Get the GetFolderPath function from http://slipstick.me/getfolderpath  
    Set MovePst = GetFolderPath("data file name\Inbox\Sent")
    Item.Move MovePst
End If

End Sub

 

Move Sent mail from Shared Mailbox

This version of the macro works with Exchange Server shared mailboxes. It can either use the GetfolderPath function or resolve the shared mailbox. The Exchange server needs to be configured to save sent items in the shared mailbox.

Private WithEvents olSentItems As Items
Dim olSent As folder
Dim olInbox As folder
 
Private Sub Application_Startup()
  Dim objNS As NameSpace
  Set objNS = Application.Session

' Uses GetFolderPath Function
'  Set olSentItems = GetFolderPath("Outlook Sales\Sent Items").Items
'  Set olInbox = GetFolderPath("Outlook Sales\Inbox")

' looks up shared mailbox name
  Dim objOwner As Outlook.Recipient
  Set NS = Application.GetNamespace("MAPI")
  Set objOwner = NS.CreateRecipient("olsales")
    objOwner.Resolve
       
 If objOwner.Resolved Then
 ' MsgBox objOwner.Name
 Set olInbox = objNS.GetSharedDefaultFolder(objOwner, olFolderInbox)

' Because using objNS.GetSharedDefaultFolder(objOwner, olFolderSentMail) triggers an error
 Set olSentFolder = olInbox.Parent.Folders("Sent Items") 
 Set olSentItems = olSentFolder.Items
 End If

Set objNS = Nothing
End Sub

Private Sub olSentItems_ItemAdd(ByVal Item As Object)

MsgBox "New Item"
    Item.Move olInbox
End Sub

 

Using Multiple IMAP accounts in Outlook 2013 and newer

Beginning with Outlook 2013, IMAP sent messages are stored in the IMAP account's sent folder and you'll need to watch each sent folder for new items.

Because each account in this example is moving sent items to the same data file, we can set the MovePst as a global variable.

This macro will also work with Exchange accounts and POP accounts that have their own pst files for incoming mail.

Private WithEvents Items As Outlook.Items
Private WithEvents GmailItems As Outlook.Items
Private WithEvents AliasItems As Outlook.Items
Dim MovePst As Outlook.Folder

Private Sub Application_Startup()
'watch default account sent folder
    Set Items = Session.GetDefaultFolder(olFolderSentMail).Items
 
' Use the GetFolderPath function from http://slipstick.me/getfolderpath  
'watch other sent folders
    Set GmailItems = GetFolderPath("me@gmail.com\[Gmail]\Sent Mail").Items
    Set AliasItems = GetFolderPath("diane@domain.com\Sent Items").Items
    
' set move pst
    Set MovePst = GetFolderPath("Outlook Data File\Sent Items")

End Sub

Private Sub Items_ItemAdd(ByVal Item As Object)
    Item.Move MovePst
End Sub

Private Sub GmailItems_ItemAdd(ByVal Item As Object)
    Item.Move MovePst
End Sub

Private Sub AliasItems_ItemAdd(ByVal Item As Object)
    Item.Move MovePst
End Sub

 

Multiple IMAP accounts in Outlook 2010 and older

If you are using multiple accounts, you can use IF statements to selectively move messages. This works with Outlook 2010 and older only, because Sent items are moved into the default pst.

Private WithEvents Items As Outlook.Items
 
Private Sub Application_Startup()
    Set Items = Session.GetDefaultFolder(olFolderSentMail).Items
End Sub

Private Sub Items_ItemAdd(ByVal Item As Object)
' Get the GetFolderPath function from http://slipstick.me/getfolderpath  

If Item.SendUsingAccount = "alias@domain.com" Then
   Set MovePst = GetFolderPath("data file name\Inbox\Sent")

ElseIf Item.SendUsingAccount = "alias@domain1.com" Then
   Set MovePst = GetFolderPath("data file name1\Inbox\Sent")

ElseIf Item.SendUsingAccount = "alias@domain2.com" Then
   Set MovePst = GetFolderPath("data file name2\Inbox\Sent")

Else
 Exit Sub

'    Item.UnRead = False
    Item.Move MovePst
End If

End Sub

You could also use Case statements to set the correct Move path.

 

Move all sent messages

This macro assumes you have only one IMAP account in Outlook (and it's set as default data file) or one or more POP accounts in Outlook using the same data file and want to move the mail sent from all accounts to a different folder.

Outlook 2013 (and newer) users who want to move IMAP messages to a local pst file can use this macro too, however, it may not move the messages immediately. Sent messages need to sync down from the IMAP server first.

Private WithEvents Items As Outlook.Items
 
Private Sub Application_Startup()
    Set Items = Session.GetDefaultFolder(olFolderSentMail).Items
End Sub

Private Sub Items_ItemAdd(ByVal Item As Object)
' You need the GetFolderPath function from http://slipstick.me/getfolderpath  
    Set MovePst = GetFolderPath("data file name\Inbox\Sent")
    Item.UnRead = False
    Item.Move MovePst
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.

Macros that run when Outlook starts or automatically need to be in ThisOutlookSession, all other macros should be put in a module, but most will also work if placed in ThisOutlookSession. (It's generally recommended to keep only the automatic macros in ThisOutlookSession and use modules for all other macros.) The instructions are below.

The macros on this page need to go into ThisOutlookSession.

Open the VBA Editor by pressing Alt+F11 on your keyboard.

To put the macro code in ThisOutlookSession:

  1. Expand Project1 and double click on ThisOutlookSession.
  2. Copy then paste the macro into ThisOutlookSession. (Click within the code, Select All using Ctrl+A, Ctrl+C to copy, Ctrl+V to paste.)

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

More Information

Messages Aren't Saved in the Sent Items Folder
Configure and Use IMAP Accounts
Choosing the Folder to Save a Sent Message In

Use a macro to move Sent Items was last modified: November 2nd, 2021 by Diane Poremsky

Related Posts:

  • Mark Sent Items as Read After Copying with a Rule
  • Use a VBA macro to monitor a folder in a secondary mailbox for new mes
    Monitor secondary mailbox folder for new messages
  • How to use an ItemAdd Macro
  • Syncing iPhone Sent Messages with Outlook

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
47 Comments
newest
oldest most voted
Inline Feedbacks
View all comments

Api (@guest_219162)
February 9, 2022 4:27 pm
#219162

Hi
What is the code for macro to archive sent emails from a specific shared mailbox to the shared sent folder?Now the sent email is archived in the sent personal folder

0
0
Reply
Diane Poremsky(@diane-poremsky)
Author
Reply to  Api
February 9, 2022 9:27 pm
#219163

This part of the shared mailbox code gets the sent folder -

 Set olInbox = objNS.GetSharedDefaultFolder(objOwner, olFolderInbox)
Set olSentFolder = olInbox.Parent.Folders("Sent Items") 

Where should it be archived?

This line moves it to the Inbox -
  Item.Move olInbox

If you want mail your send from the shared mailbox to go into the shared mailbox sent folder, that can be done using a registry key or the admin can configure exchange to do it.
Save Sent Items in Shared Mailbox Sent Items folder (slipstick.com)

1
0
Reply
Fabiano Cid (@guest_218414)
June 15, 2021 2:28 pm
#218414

Hi
Dear Diane,

Can you explain in a short video?

I need move all messages from IMAP sent folder to a PST outlook 2019 folder every time.

0
0
Reply
Tim (@guest_217884)
April 11, 2021 2:07 pm
#217884

Hi, I have multiple POP3 inboxes in Outlook and a single IMAP account. Can you provide the complete VBA code I can use to ensure that any Sent emails from any of the POP3 accounts (wildcard ideally rather than having to specify each account) also get copied/moved to the sent folder of the IMAP account?

0
0
Reply
Diane Poremsky(@diane-poremsky)
Author
Reply to  Tim
November 2, 2021 3:11 pm
#218854

A wild card won't work - you need to watch each Sent folder.

Private WithEvents olSentItemsA As Items
Private WithEvents olSentItemsB As Items
Private WithEvents olSentItemsC As Items

Set olSentItemsA = GetFolderPath("AcctA\Sent Items").Items
Set olSentItemsB = GetFolderPath("AcctB\Sent Items").Items
Set olSentItemsC = GetFolderPath("AcctC\Sent Items").Items

And you need an ItemAdd for each -

Private Sub olSentItemsA_ItemAdd(ByVal Item As Object)
  Item.Move olInbox
End Sub

Private Sub olSentItemsB_ItemAdd(ByVal Item As Object)
  Item.Move olInbox
End Sub

Private Sub olSentItemsC_ItemAdd(ByVal Item As Object)
  Item.Move olInbox
End Sub

0
0
Reply
Tumer (@guest_214645)
January 22, 2020 7:50 am
#214645

Dear Diane,
ı hope you are well, I would like when ı try to modified your code in outlook ,outlook cant find recipient or To . would you help me.

Private WithEvents Items As Outlook.Items

Private Sub Application_Startup()
Set Items = Session.GetDefaultFolder(olFolderSentMail).Items
End Sub

Private Sub Items_ItemAdd(ByVal Item As Object)
Dim RecipientAddress As Variant

If RecipientAddress = " John, Smith (Canada) " or " john.smith@example.com"
' Get the GetFolderPath function from http://slipstick.me/getfolderpath
Set MovePst = Outlook.Session.Folders("2020").Folders("sent").Folders("ABC")
Item.Move MovePst
'End If

End Sub

when I made If statement with recipient / To doesnt check and move correct destionation.

what is my mistake ?

best Regards
Tumer

0
0
Reply
Abhijeet (@guest_198293)
April 28, 2016 10:06 pm
#198293

Hi

I have macro that macro send emails with attachment but 500 emails to send so i can not add those in sent item folder

from setting i remove this add after sending email to sent item folder

problem is some emails send without attachments so i want identify which emails sent with & without attachments so please tell me any macro that copy paste emails from sent item folder paste in particular folder (Folder is created on Desktop) & then delete that permanently

Please help me

0
0
Reply
Meaning (@guest_197717)
April 8, 2016 12:54 am
#197717

Please help me! I want save sent item as .msg to disk outlook use IMAP protocol

0
0
Reply
Diane Poremsky(@diane-poremsky)
Author
Reply to  Meaning
April 8, 2016 11:15 pm
#197738

You want to do this using macros? See https://www.slipstick.com/developer/code-samples/save-selected-message-file/ - there is one for sent messages. If you just want to save one or two now and again, you can drag the message from sent items to the hard drive. or open it and use the same command.

0
0
Reply
Pietro (@guest_196617)
February 19, 2016 5:06 pm
#196617

Thanks for the tutorial. I would like to use this script for a slightly different function: I need to save the emails added to the "Sent" folder in a local archive, without removing them from "Sent" folder.
I tried this:
Private Sub Items_ItemAdd(ByVal Item As Object)
If Item.SendUsingAccount = "name.surname@domain.com" Then
Set MovePst = GetFolderPath("abcd\Fold")
Dim Copied As Object
Set Copied= Item.copy
Copied.Move MovePst
End If
End Sub

But it returns "Run-time error '-2147221233 (8004010f)'"
Can you help with this? Thank you in advance.

0
0
Reply
Fabio (@guest_190962)
May 16, 2015 6:11 am
#190962

I was finding IMAP way too complicated...I decided to go back to all pop accounts but I still would like to try something else. What are your thoughts on Google Apps Sync for Outlook?

0
0
Reply

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

Latest EMO: Vol. 30 Issue 15

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
  • Remove a password from an Outlook *.pst File
  • Reset the New Outlook Profile
  • Maximum number of Exchange accounts in an Outlook profile
  • Save Attachments to the Hard Drive
  • How to Hide or Delete Outlook's Default Folders
  • 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
  • Use PowerShell to Delete Attachments
  • Remove RE:, FWD:, and Other Prefixes from Subject Line
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

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

Use PowerShell to Delete Attachments

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

Newest Code Samples

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

Use PowerShell or VBA to get Outlook folder creation date

Rename Outlook Attachments

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