Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8227643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:11:35+00:00 2026-06-07T16:11:35+00:00

I am writing an application which has to get items that can be matched

  • 0

I am writing an application which has to get items that can be matched with rules.

//new messages goes here
void items_ItemAdd(object Item)
    {
        //all rules
        Rules rules = Application.Session.DefaultStore.GetRules();

        Outlook.MailItem mail = (Outlook.MailItem)Item;

        if (mail != null)
        {
            // I need to find out if mail matches with one of the rule. And handle in an appropriate way.
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T16:11:38+00:00Added an answer on June 7, 2026 at 4:11 pm

    The only way to check which rules apply to which items is by enumerating the Rule Conditions (and excluding rule exceptions) manually for each MailItem. The rule engine works by executing each rule you have defined via Rule.Execute – it doesn’t provide a mechanism to preview affected items.

    Here is an (untested) example for reference on how to match a contains subject rule (olConditionSubject). You would also need to handle other Rule Conditions types.

    if (mail != null)
    {
        foreach (Outlook.Rule rule in rules)
        {
           foreach (Outlook.RuleCondition condition in rule.Conditions)
           {
             if (condition is TextRuleCondition)
             {
                Outlook.TextRuleCondition trc = condition as Outlook.TextRuleCondition;
                if (trc.ConditionType == Outlook.OlRuleConditionType.olConditionSubject)
                {
                  // TODO: handle Rule.Exceptions conditions
                  bool containsSubject = mail.Subject.Contains(trc.Text);
                }
             }
           }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing an application which has an authenticity mechanism, using HMAC-sha1, plus a
I am writing a server application which has a large amount of source code.
Abstract I am writing an application which has a few object caches. The way
Greetings, I'm in the middle of writing a Flash application which has multilingual support.
TL;DR Summary: I need a single command-line application which I can use to get
I am writing an application which needs to get the colors of pixels on
I am writing a Delphi 2010 application. It has many files, two of which
Background I am writing an application which has two distinct functions. Load a GPX
I am currently writing a .Net application in c#, which has two main components:
I'm writing a C# application which has IronPython (2.0.1) embedded in it. The idea

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.