CreateRuleOperation CreateRuleOperation CreateRuleOperation Class


Represents an operation to create an Inbox rule.

public ref class CreateRuleOperation sealed : Microsoft::Exchange::WebServices::Data::RuleOperation
public sealed class CreateRuleOperation : Microsoft.Exchange.WebServices.Data.RuleOperation
Public NotInheritable Class CreateRuleOperation
Inherits RuleOperation


The following example creates a rule with the name "MoveInterestingToJunk". The rule has a Conditions property that specifies that whenever an e-mail message arrives that has the string "Interesting" in the subject line, the message is to be moved to the Junk E-mail folder. The rule is uploaded to the server in the service.UpdateInboxRules(new RuleOperation[] { createOperation }, true) line.

// Create an Inbox rule.
// If "Interesting" is in the message's subject line, move it into the Junk E-mail folder.
Rule newRule = new Rule();
newRule.DisplayName = "MoveInterestingToJunk";
newRule.Priority = 1;
newRule.IsEnabled = true;
newRule.Actions.MoveToFolder = WellKnownFolderName.JunkEmail;

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


Inbox rules are sets of Conditions and associated Actions that enable clients to automatically organize, categorize, and act on messages as the messages are delivered to a folder.

This class derives from the RuleOperation class.

When a rule is created, it is stored on the Exchange server. When a message arrives, the Exchange server evaluates the message and determines whether it has fulfilled any rule Conditions. If it has, the Exchange server will then process the message according to the rule Actions. 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.


CreateRuleOperation() CreateRuleOperation() CreateRuleOperation()

Initializes a new instance of the CreateRuleOperation class.

CreateRuleOperation(Rule) CreateRuleOperation(Rule) CreateRuleOperation(Rule)

Initializes a new instance of the CreateRuleOperation class with the specified rule.


Rule Rule Rule

Gets or sets the rule to be created.

Applies to