Skip to main content

How to mark unread emails older than specific days as read automatically in Outlook?

Author: Xiaoyang Last Modified: 2018-04-10

If there are multiple unread emails in your Inbox folder, normally, you can apply the Mark All as Read feature to mark all unread emails as read emails manually. But, have you ever tried to mark unread emails which are older than specific days as read automatically in Outlook without setting it manually each time?

Mark unread emails older than specific days as read automatically with VBA code


Mark unread emails older than specific days as read automatically with VBA code

To auto mark all unread emails older than specific days as read, the following VBA code can do you a favor:

1. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.

2. In the Microsoft Visual Basic for Applications window, double click ThisOutlookSession from the Project1(VbaProject.OTM) pane to open the mode, and then copy and paste the below code into the blank module.

VBA code: Auto mark unread emails older than specific days as read:

Private Sub Application_Startup()
        Call MarkOldUnreadEmailsAsRead
    End Sub
    Private Sub MarkOldUnreadEmailsAsRead()
    Dim xInboxFld As Outlook.Folder
    Dim xAccount As Account
    On Error GoTo L1
    For Each xAccount In Outlook.Application.Session.Accounts
        Set xInboxFld = xAccount.DeliveryStore.GetDefaultFolder(olFolderInbox)
        Call Processfolders(xInboxFld)
    Next xAccount
L1:     Exit Sub
    End Sub
    Private Sub Processfolders(ByVal InboxFld As Outlook.Folder)
    Dim xItems As Outlook.Items
    Dim i As Long
    Dim xSubFld As Outlook.Folder
    On Error Resume Next
    Set xItems = InboxFld.Items
    For i = 1 To xItems.Count
        If DateDiff("d", xItems(i).ReceivedTime, Now) >= 15 Then
           If xItems(i).UnRead = True Then
              xItems(i).UnRead = False
              xItems(i).Save
           End If
        End If
    Next
    If InboxFld.Folders.Count > 0 Then
       For Each xSubFld In InboxFld.Folders
           Call Processfolders(xSubFld)
       Next
    End If
End Sub

Note: In the above code, you can change the number of days within this script: If DateDiff("d", xItems(i).ReceivedTime, Now) >= 15 Then to your own needed.

3. Then save and close this code window, since then, every time when you launch Outlook, all unread emails which are older than predefined days will be marked as read automatically at once.

Note: This code is only available to the default data account.


Best Office Productivity Tools

Breaking News: Kutools for Outlook Launches Free Version!

Experience the all-new Kutools for Outlook FREE version with 70+ incredible features, yours to use FOREVER! Click to download now!

๐Ÿค– Kutools AI : Instant pro emails with AI magic--one-click to genius replies, perfect tone, multilingual mastery. Transform emailing effortlessly! ...

๐Ÿ“ง Email Automation: Auto Reply (Available for POP and IMAP)  /  Schedule Send Emails  /  Auto CC/BCC by Rules When Sending Email  /  Auto Forward (Advanced Rules)   /  Auto Add Greeting   /  Automatically Split Multi-Recipient Emails into Individual Messages ...

๐Ÿ“จ Email Management: Recall Emails  /  Block Scam Emails by Subjects and Others  /  Delete Duplicate Emails  /  Advanced Search  /  Consolidate Folders ...

๐Ÿ“ Attachments ProBatch Save  /  Batch Detach  /  Batch Compress  /  Auto Save   /  Auto Detach  /  Auto Compress ...

๐ŸŒŸ Interface Magic: ๐Ÿ˜ŠMore Pretty and Cool Emojis   /  Remind you when important emails come  /  Minimize Outlook Instead of Closing ...

๐Ÿ‘ One-click Wonders: Reply All with Incoming Attachments  /   Anti-Phishing Emails  /  ๐Ÿ•˜Show Sender's Time Zone ...

๐Ÿ‘ฉ๐Ÿผโ€๐Ÿคโ€๐Ÿ‘ฉ๐Ÿป Contacts & Calendar: Batch Add Contacts From Selected Emails  /  Split a Contact Group to Individual Groups  /  Remove Birthday Reminders ...

Instantly unlock Kutools for Outlook with a single clickโ€”permanently free. Don't wait, download now and boost your efficiency!

kutools for outlook features1 kutools for outlook features2
 

 

 

Comments (1)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
How do I modify the code to target a specific folder?
There are no comments posted here yet
Leave your comments
Posting as Guest
Rate this post:
0   Characters
Suggested Locations