AtTips, Tricks & Tools
for Microsoft® Office Outlook®

Green arrowBuy an Upgrade now

Deutsch
Tips Programming Mark all e-mails as read

Mark all e-mails as read

If you want to mark all items in multiple folders as read you can do this with the following code. To do so please add for each folder a new line starting with "Call MarkAsRead(...)" in the procedure "MarkItemsAsRead". Please do not forget to activate this lines by removing the apostroph.

To use this example please read the important notes and have a look to the workshop Use VBA in Outlook®. Please insert this code into a new module (Insert -> Module in the VBA-Editor).

For Outlook® 2000, Outlook® 2002, Outlook® 2003, Outlook® 2007

Option Explicit
 
Public Sub MarkItemsAsRead()
 
    '=====================================================================
    ' Marks all items of folders as read
    ' (c) Peter Marchert - http://www.outlook-stuff.com
    ' 2009-02-01 Version 1.0.0
    '=====================================================================
 
    '---------------------------------------------------------------------
    ' Mark all items of the inbox as read
    '---------------------------------------------------------------------
    Call MarkAsRead(Outlook.Session.GetDefaultFolder(olFolderInbox))
 
    '---------------------------------------------------------------------
    ' With "GetDefaultFolder" you access always the default store. If you 
    ' use multiple pst files and/or have more stores, please use the 
    ' following syntax to access to other stores.
    ' Comment out the next line and fit the number (1) and the folder
    ' names to your needs (see also "ListFolders").
    '---------------------------------------------------------------------
    'Call MarkAsRead(Outlook.Session.Folders(1).Folders("Inbox").Folders("1"))
 
    '---------------------------------------------------------------------
    ' If you have a deeper folder strukture, simply add one more "Folders".
    '---------------------------------------------------------------------
    'Call MarkAsRead(Outlook.Session.Folders(1).Folders("Inbox").Folders("1").Folders("2"))
 
    '---------------------------------------------------------------------
    ' Mark all items of the current folder as read
    '---------------------------------------------------------------------
    'Call MarkAsRead(Outlook.ActiveExplorer.CurrentFolder)
 
End Sub
 
Private Sub MarkAsRead(ByVal objFolder As Object)
 
    '=====================================================================
    ' Marks all items of the folder "objFolder" as read
    '=====================================================================
 
    Dim objItems As Outlook.Items
    Dim objItem As Object
 
    On Error Resume Next
 
    '---------------------------------------------------------------------
    ' Reference all items in the folder
    '---------------------------------------------------------------------
    Set objItems = objFolder.Items
 
    '---------------------------------------------------------------------
    ' Process all items
    '---------------------------------------------------------------------
    For Each objItem In objItems
 
        '-----------------------------------------------------------------
        ' If not already marked as read mark as read 
        '-----------------------------------------------------------------
        If objItem.UnRead Then objItem.UnRead = False
 
    Next
 
    '---------------------------------------------------------------------
    ' Clean Up
    '---------------------------------------------------------------------
    Set objItem = Nothing
    Set objItems = Nothing
    Set objFolder = Nothing
 
End Sub
 
Private Sub ListFolders()
 
    '=====================================================================
    ' Lists all existing stores in the direct window (Ctrl+G)
    '=====================================================================
 
    Dim objFolder As Object
    Dim lngCounter As Long
 
    For Each objFolder In Outlook.Session.Folders
        lngCounter = lngCounter + 1
        Debug.Print lngCounter & " - " & objFolder.Name
    Next
 
    Set objFolder = Nothing
 
End Sub

Newsletter

NewsletterSorry, the Newsletter Service from outlook-stuff.com is currently only available in German. If you are nevertheless interested you may translate them with an online translation service.

Cart

Your cart is empty
Show the product page...

Product State

Updates

Report a bug

On this page you have a bug:

Newsflash

Was ist aus planet-outlook.de geworden?

Sorry, no translation available.

Das deutschsprachige Portal "Planet Outlook" ist seit Mitte April 2011 nicht mehr erreichbar.

 Read more...

Lifetime Updates incl.!

Yes, it is really true: In outlook-stuff.com, you pay not a penny extra for updates!
Lifetime Updates incl.!

Pay once = use forever!

to the Shop...

Product Range

Close