Marking automatically moved to folders (using rules) messages as Unread in Outlook 2010 / Gmail

0

When using outlook 2010 and Gmail / IMAP using a rule to move a message to a folder also marks it as read. There is a previous question on this topic but no answers that work for me. The first answer says that should not happen (incorrect when using gmail / IMAP) and the second offers a VBA option that does not appear to do anything. I tried this code with no luck:

Sub unread(MyItem As MailItem) MyItem.unread = True End Sub

Any suggestions other than don't use outlook with gmail (which I wish was an option)? Do I need to move the message with vba also?

EDIT: No, mark as read is not checked.

amcfall

Posted 2015-02-02T17:01:22.483

Reputation: 1

This may seem like a silly question, but is the "Mark as read" option selected within the rule settings? Sometimes Outlook thinks you want it marked as read when it is moved. – CharlieRB – 2015-02-02T17:19:55.693

Answers

0

You can use the Items.ItemAdd event

How to process incoming messages in Microsoft Outlook

The code goes in the built-in ThisOutlookSession module.

You monitor each folder separately!

Declare an Items collection object for each folder WithEvents

Instantiate each Items collection object in the Application_Startup event handler

Add an ItemAdd event handler for each Items collection object

Option Explicit

' Sample folder directly under the inbox
Private WithEvents SubfolderAItems As Items

' Sample folder directly under SubfolderA 
Private WithEvents SubfolderBItems As Items 

Private Sub Application_Startup()

    Dim objNS As NameSpace
    Set objNS = Application.Session

    ' instantiate objects declared WithEvents
    Set SubfolderAItems = objNS.GetDefaultFolder(olFolderInbox).Folders("SubfolderA").Items
    Set SubfolderBItems = objNS.GetDefaultFolder(olFolderInbox).Folders("SubfolderA").Folders("SubfolderB").Items

    Set objNS = Nothing

End Sub

' Note: Changes behaviour of dragging items into the folder as well.
Private Sub SubfolderAItems_ItemAdd(ByVal Item As Object)
    Item.unread = True
End Sub  

Private Sub SubfolderBItems_ItemAdd(ByVal Item As Object)
    Item.unread = True
End Sub

niton

Posted 2015-02-02T17:01:22.483

Reputation: 1 724