Automatically Move Emails to Sub-Folders and Mark Them as Read in Outlook

Abstract: Resolve the inability of Outlook rules to mark emails as read during automatic moves by using a VBA macro.

Created: 2026-10-04 by
To automatically move emails to sub-folders and mark them as read in Outlook, you must create a VBA macro that iterates through selected items, moves each message to the target folder, and sets its UnRead property to false. This approach provides precise control over individual messages without relying on server-side rules that may not support marking items as read directly during the move operation.

Prerequisites for VBA Automation

Before writing any code, ensure that your Outlook installation allows macros to run. Microsoft disables macros by default for security reasons. You can enable this by navigating to File > Options > Trust Center > Trust Center Settings > Macro Settings. Select Enable all macros or Notify for all macros if you want to be prompted before running the script. Additionally, you need to know the exact name of the destination sub-folder where you want the emails to reside. For example, if your folder structure is Inbox > Work > Projects, you will need to reference this hierarchy correctly in your code.

Accessing the VBA Editor

Open Outlook and press Alt + F11 to launch the Visual Basic for Applications (VBA) editor. In the Project Explorer window on the left, locate ThisOutlookSession. If you do not see it, go to View > Project Explorer. Double-click ThisOutlookSession to open the code module. This is where you will paste the macro code. It is crucial to save your work frequently within the VBA editor using Ctrl + S to prevent data loss if Outlook crashes during testing.

The VBA Macro Code

Paste the following code into the ThisOutlookSession module. This script assumes you have one or more emails selected in your current view when you run the macro. It moves them to a specific sub-folder named Processed under the default Inbox and marks them as read.
Sub MoveAndMarkAsRead()
    Dim objNamespace As NameSpace
    Dim objFolder As MAPIFolder
    Dim objItem As Object
    Dim objDestFolder As MAPIFolder
    
    ' Get the Outlook namespace
    Set objNamespace = Application.GetNamespace("MAPI")
    
    ' Define the destination folder path
    ' Adjust "Processed" to your desired sub-folder name
    Set objDestFolder = objNamespace.GetDefaultFolder(olFolderInbox).Folders("Processed")
    
    ' Loop through selected items
    If Application.ActiveExplorer.Selection.Count > 0 Then
        For Each objItem In Application.ActiveExplorer.Selection
            ' Check if the item is a MailItem
            If TypeOf objItem Is MailItem Then
                With objItem
                    ' Mark as read
                    .UnRead = False
                    ' Save changes to mark as read before moving
                    .Save
                    
                    ' Move the item to the destination folder
                    .Move objDestFolder
                End With
            End If
        Next objItem
    Else
        MsgBox "No items selected.", vbExclamation
    End If
    
    ' Clean up objects
    Set objDestFolder = Nothing
    Set objItem = Nothing
    Set objFolder = Nothing
    Set objNamespace = Nothing
End Sub

Customizing the Destination Folder

The line Set objDestFolder = objNamespace.GetDefaultFolder(olFolderInbox).Folders("Processed") is critical. If your destination folder is nested deeper, such as Inbox > Archive > 2023, you must adjust the path accordingly: .Folders("Archive").Folders("2023"). Ensure that the folder names match exactly, including case sensitivity in some environments, though Outlook is generally forgiving. If the folder does not exist, the macro will throw an error. To avoid this, you can add error handling to create the folder if it is missing, but for simplicity, we assume the folder already exists.

Running the Macro

Return to the main Outlook window. Select the emails you wish to process. Press Alt + F8 to open the Macro dialog box. Select MoveAndMarkAsRead from the list and click Run. The selected emails will immediately disappear from your current view, appear in the destination sub-folder, and be marked as read. If you encounter a security warning, confirm that you trust the macro. Note that this method processes only the currently selected items. To automate this for incoming emails, you would need to use an Application_NewMailEx event handler, which requires more complex coding to identify new messages. For more advanced email management techniques, consider exploring Automatically Move Emails to Sub-Folders and Mark Them as Read in Outlook for alternative rule-based approaches.

Troubleshooting Common Issues

If the macro fails to run, check the Trust Center settings again. Ensure that the macro is not being blocked by your organization's group policy. If you receive a "Object Required" error, verify that the destination folder path is correct. If the emails are not marked as read, ensure that the .Save command is executed before the .Move command, as moving an item can sometimes reset its status depending on Outlook version and sync behavior.

Performance Considerations

Running this macro on thousands of emails at once may cause Outlook to become unresponsive. It is best practice to select batches of emails (e.g., 50-100 at a time) rather than selecting your entire inbox. For large-scale automation, consider using Outlook Rules with VBA triggers or third-party add-ins designed for bulk processing.

Frequently Asked Questions

Can I apply this rule to all incoming emails automatically?

Yes, but you must modify the code to use the Application_NewMailEx event instead of manually selecting items. This requires adding code to the Application_Startup event to initialize the listener and carefully handling the entry IDs of new messages to retrieve and process them.

What happens if the destination folder does not exist?

The macro will throw a runtime error because it cannot move an item to a non-existent folder. You should either pre-create the folder manually or add error-handling logic in VBA to create the folder structure dynamically if it is missing.

Does this work with shared mailboxes?

Yes, provided you have the necessary permissions to access the shared mailbox and the destination folder. You will need to change the GetDefaultFolder call to point to the shared mailbox folder path, such as objNamespace.Folders("SharedName").Folders("Inbox").

Why are my emails still showing as unread after running the macro?

This often occurs if the .Save command is omitted or placed after the .Move command. Moving the item can trigger a synchronization event that resets the read status. Always set .UnRead = False and then call .Save before executing .Move.

How do I assign a keyboard shortcut to this macro?

You can assign a shortcut by going to File > Options > Customize Ribbon > Keyboard Shortcuts. However, VBA macros in Outlook are not always assignable via the standard UI. A more reliable method is to add a button to the Quick Access Toolbar that runs the macro, or use a tool like AutoHotkey to simulate the Alt + F8 sequence.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More