Edit

Share via


Rule Class

Definition

Represents an individual Inbox rule in the mailbox.

public ref class Rule sealed : Microsoft::Exchange::WebServices::Data::ComplexProperty
public sealed class Rule : Microsoft.Exchange.WebServices.Data.ComplexProperty
Public NotInheritable Class Rule
Inherits ComplexProperty
Inheritance

Examples

The following example creates a new Rule and saves it to the messaging server. The rule contains an Actions and Conditions property. The Actions are:

  • The e-mail message is sent to the JunkEmail folder.
  • Assign a category of "Immediate".
  • Assign a category of "Internal use only".

The Conditions are:

  • The e-mail message contains the word "Interesting" in the subject.
// Create an inbox rule.
// If "Interesting" is in the e-mail's subject, move it into the Junk folder
// and assign two categories to the message.
Rule newRule = new Rule();
newRule.Actions.MoveToFolder = WellKnownFolderName.JunkEmail;
newRule.Conditions.ContainsSubjectStrings.Add("Interesting");
newRule.DisplayName = "MoveInterestingToJunk";
newRule.IsEnabled = true;

newRule.Priority = 1;
newRule.Actions.AssignCategories.Add("Immediate");
newRule.Actions.AssignCategories.Add("Internal use only.");

// Create the CreateRuleOperation.
CreateRuleOperation createRuleOperation = new CreateRuleOperation(newRule);
service.UpdateInboxRules(new RuleOperation[] { createRuleOperation }, true);

Remarks

An Inbox rule is a set of Conditions, Exceptions, and associated Actions that enable clients to automatically organize, categorize, and act on messages as the messages are delivered to a folder. For example, a Rule can be created to require that any incoming mail that contains a certain string in the subject be automatically moved to a predetermined folder. Rule evaluation is triggered when e-mail messages are delivered in a user's mailbox or when messages are first saved to a folder. The Conditions in a Rule are evaluated against the properties of the incoming message. If the Conditions evaluate to true, the rule Actions are executed by the server.

Constructors

Rule()

Initializes a new instance of the Rule class.

Properties

Actions

Gets the actions to be taken on a message when the Conditions are fulfilled.

Conditions

Gets the conditions that when fulfilled, will trigger the rule Actions for that Rule.

DisplayName

Gets or sets a string value that contains the display name of a Rule.

Exceptions

Gets the Exceptions that represents all the available rule exception conditions for the inbox rule.

Id

Gets or sets the Rule identifier.

IsEnabled

Gets or sets whether the Rule is enabled.

IsInError

Gets a value that indicates whether the Rule is in an error condition.

IsNotSupported

Gets a value that indicates whether the Rule cannot be modified with the managed code APIs.

Priority

Gets or sets the Rule priority, a value that indicates the order in which a Rule should be run.

Applies to