How to create a rule with the Mark It As Read action in C# RRS feed

  • Question

  • When I create a rule in Outlook 2013, one of the actions I can select is "mark it as read". However, the `Microsoft.Office.Interop.Outlook.Actions` type in the C# package does not seem to provide a way to interact with this action. There seems to be an `OlRuleActionType` of `olRuleActionMarkRead` but I do not see a way to create an action with an arbitrary type. How can I tell if an existing rule has this action enabled or create new rules with this action enabled using C#?
    Tuesday, May 8, 2018 1:47 PM

All replies

  • Hello,

    You may consider handling the NewMailEx event of the Application class where you may process incoming emails. his event fires once for every received item that is processed by Microsoft Outlook. The item can be one of several different item types, for example, MailItem , MeetingItem , or SharingItem . The EntryIDsCollection string contains the Entry ID that corresponds to that item. Note that this behavior has changed from earlier versions of the event when the EntryIDCollection contained a list of comma-delimited Entry IDs of all the items received in the Inbox since the last time the event was fired.

    The  NewMailEx event fires when a new message arrives in the Inbox and before client rule processing occurs. You can use the Entry ID returned in the EntryIDCollection array to call the NameSpace.GetItemFromID method and process the item. Use this method with caution to minimize the impact on Outlook performance. However, depending on the setup on the client computer, after a new message arrives in the Inbox, processes like spam filtering and client rules that move the new message from the Inbox to another folder can occur asynchronously. You should not assume that after these events fire, you will always get a one-item increase in the number of items in the Inbox.

    Unfortunately not all rule actions like olRuleActionMarkRead supported when creating new rules programmatically. See Specifying Rule Actions for more information. 

    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Tuesday, May 8, 2018 2:45 PM