Search code examples
outlookoutlook-2013

Macro in outlook to mark emails as read


I want to use a macro in outlook 2013. This macro is supposed to mark any emails arriving a specific folder ('work' folder) as read. I'm not familiar with vb. Any help/guidance is much appreciated!


Solution

  • No sure, I have heard this one before of wanting emails automatically read. You have two options:

    a) Use Ctrl-A (select all mail in folder), Ctrl-Q (mark selection as read)

    b) Use New Email Event something like:

    Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
        vID = Split(EntryIDCollection, ",")
        Dim i as Long, objMail as Outlook.MailItem
        For i = 0 To UBound(vID)
            Set objMail = Application.Session.GetItemFromID(vID(i))
            objMail.Unread = False
        Next i
    End Sub
    
    
    Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
        ' version to select folder
        Dim i As Long, objMail As Outlook.MailItem, mpfInbox As Outlook.Folder
        Set mpfInbox = Application.GetNamespace("MAPI").Folders("YOURACCOUNT").Folders("[Gmail]").Folders("Sent Mail")
        For i = 1 To mpfInbox.Items.Count
            If mpfInbox.Items(i).Class = olMail Then
                Set objMail = mpfInbox.Items.Item(i)
                objMail.UnRead = False
            End If
        Next i
    End Sub