SetRuleOperation Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Represents an operation to update an Inbox rule.
public ref class SetRuleOperation sealed : Microsoft::Exchange::WebServices::Data::RuleOperation
public sealed class SetRuleOperation : Microsoft.Exchange.WebServices.Data.RuleOperation
Public NotInheritable Class SetRuleOperation
Inherits RuleOperation
- Inheritance
Examples
The following example searches the RuleCollection class to find an existing rule with the name "MoveInterestingToJunk" from the user's mailbox. If the rule exists, the Conditions properties are changed. The Conditions property removes the existing subject string filter and applies the new Conditions property that specifies that whenever an e-mail message arrives that has a string of "This is Junk" in the subject, the Exchange server is to take the existing actions. The rule is uploaded to the server when the service.UpdateInboxRules(new RuleOperation[] { setRuleOperation }, true) line is executed.
// Modify the "MoveInterestingToJunk" rule, if it exists.
// Get the RuleCollection.
RuleCollection ruleCollection = service.GetInboxRules("User1@Contoso.com");
foreach (Rule ruleinCollection in ruleCollection)
{
if (ruleinCollection.DisplayName == "MoveInterestingToJunk")
{
ruleinCollection.Conditions.ContainsSubjectStrings.Clear();
ruleinCollection.Conditions.ContainsSubjectStrings.Add("This is Junk");
SetRuleOperation setRuleOperation = new SetRuleOperation(ruleinCollection);
service.UpdateInboxRules(new RuleOperation[] { setRuleOperation }, true);
}
}
Remarks
You can use this class to update the conditions and actions of an existing rule.
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. This class enables you to change the conditions or actions of a rule.
Constructors
SetRuleOperation() |
Initializes a new instance of the SetRuleOperation class. |
SetRuleOperation(Rule) |
Initializes a new instance of the SetRuleOperation class with the specified rule. |
Properties
Rule |
Gets or sets the rule to be updated. |