0

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!

MANOJ GOPI
  • 1,279
  • 10
  • 31
RamBracha
  • 381
  • 1
  • 5
  • 7

2 Answers2

1

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
Jeanno
  • 2,769
  • 4
  • 23
  • 31
  • Thanks for the response. How do I use the macro for a specific folder and not every email item? – RamBracha Jan 14 '15 at 20:45
  • Looks like the revised code processes mpfInbox for every mail received. ItemAdd for 'work' folder would be appropriate. http://stackoverflow.com/questions/11263483/how-do-i-trigger-a-macro-to-run-after-a-new-mail-is-received-in-outlook – niton Feb 19 '15 at 02:37
0

You can set up a rule which can trigger your macro.

I'd not suggest working with the NewMailEx event because it is not fired in some case and may introduce issues. See Outlook NewMail event unleashed: the challenge (NewMail, NewMailEx, ItemAdd) for more information.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45