Rule 类

定义

表示邮箱中的单个收件箱规则。

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
继承

示例

以下示例创建一个新规则并将其保存到消息服务器。 规则包含 ActionsConditions 属性。 是 Actions

  • 电子邮件将发送到 JunkEmail 文件夹。
  • 分配类别“即时”。
  • 分配“仅限内部使用”的类别。

Conditions

  • 电子邮件在主题中包含“有趣”一词。
// 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);

注解

收件箱规则是一组 ConditionsExceptions和 关联的 Actions ,使客户端能够在邮件传递到文件夹时自动组织邮件、对邮件进行分类和操作。 例如,可以创建 , Rule 要求将主题中包含特定字符串的任何传入邮件自动移动到预先确定的文件夹。 Rule 在用户邮箱中传递电子邮件或首次将邮件保存到文件夹时,将触发评估。 Conditions根据传入消息的属性计算 中的 RuleConditions如果 计算结果为 true,则规则Actions由服务器执行。

构造函数

Rule()

初始化 Rule 类的新实例。

属性

Actions

获取满足条件时要对消息执行的操作。

Conditions

获取满足时将触发该规则的“操作”规则的条件。

DisplayName

获取或设置一个字符串值,该值包含 Rule 的显示名称。

Exceptions

获取表示收件箱规则的所有可用规则例外条件的异常。

Id

获取或设置规则标识符。

IsEnabled

获取或设置是否启用规则。

IsInError

获取一个值,该值指示 Rule 是否处于错误状态。

IsNotSupported

获取一个值,该值指示是否无法使用托管代码 API 修改规则。

Priority

获取或设置规则优先级,该值指示规则的运行顺序。

适用于