DeleteRuleOperation class

Represents an operation to delete an Inbox rule.

Namespace:  Microsoft.Exchange.WebServices.Data
Assembly:  Microsoft.Exchange.WebServices (in Microsoft.Exchange.WebServices.dll)

public sealed class DeleteRuleOperation : RuleOperation

You can delete an existing Rule class object by using this class.

This class derives from the RuleOperation class.

The following example searches the RuleCollection class to find an existing Rule object with the name "MoveInterestingToJunk" from the user's mailbox. If the Rule exists, the Rule is deleted when the service.UpdateInboxRules(new RuleOperation[] { setRuleOperation }, true) line is executed.

// Create the DeleteRuleOperation.
// Delete the rule "MoveInterestingToJunk", if it exists.
// Get the RuleCollection.
RuleCollection ruleCollection = service.GetInboxRules("");
foreach (Rule ruleinCollection in ruleCollection)
    if (ruleinCollection.DisplayName == "MoveInterestingToJunk")
        DeleteRuleOperation deleteRuleOperation = new DeleteRuleOperation(ruleinCollection.Id);
        service.UpdateInboxRules(new RuleOperation[] { deleteRuleOperation }, true);

Any public static ( in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.