指定规则条件Specifying Rule Conditions

使用对象模型支持最常用规则的规则操作和条件。The Rules object model supports the most commonly used rule actions and conditions. 每个**规则** 对象都表示对于该规则的规则操作的**操作** 属性以及**条件** 属性和**Exceptions** 属性表示该规则的条件。Each Rule object has an Actions property that represents the rule actions for that rule, as well as a Conditions property and an Exceptions property that represent the conditions for that rule. 本主题介绍如何 Rules 对象模型支持规则条件。This topic describes how the Rules object model supports rule conditions.

由**作为 RuleConditions** 集合对象表示的规则的规则条件。Rule conditions for a rule are represented by a RuleConditions collection object. RuleConditions对象具有属性对应于在规则中的每个常用的规则条件。A RuleConditions object has properties that correspond to each commonly used rule condition in a rule. 如果规则指定两个条件-例如,消息非常重要和主题包含特定词语的然后的**重要性** 和规则的RuleConditions集合对象的**Subject** 属性将返回各自的规则条件启用的对象 (RuleCondition.EnabledTrue)。For example, if a rule specifies two conditions - the message is important and the subject contains certain words - then the Importance and Subject properties of the rule's RuleConditions collection object will return respective rule condition objects that are enabled (RuleCondition.Enabled is True).

未在规则中指定的条件将不会启用相应的**RuleCondition** 对象 (RuleCondition.EnabledFalse)。Conditions that are not specified in a rule will not be enabled in the corresponding RuleCondition object (RuleCondition.Enabled is False). 规则条件对象由RuleCondition对象或自定义对象派生自RuleCondition对象。Rule condition objects are represented by either the RuleCondition object or customized objects derived from the RuleCondition object. 在最后一个示例中,则RuleConditions.Importance属性将返回一个**ImportanceRuleCondition** 对象,并RuleConditions.Subject属性将返回一个**TextRuleCondition** 对象,这两种派生从RuleCondition对象。In the last example, the RuleConditions.Importance property will return an ImportanceRuleCondition object, and the RuleConditions.Subject property will return a TextRuleCondition object, both of which are derived from the RuleCondition object. RuleCondition对象和其派生的对象有ConditionType属性指示的规则条件的类型,例如, ImportanceRuleCondition.ConditionType 将指示的值olConditionImportance,和**TextRuleCondition.ConditionType** 将指示olConditionSubjectThe RuleCondition object and its derived objects have the ConditionType property that will indicate the type of the rule condition, for example, ImportanceRuleCondition.ConditionType will indicate the value olConditionImportance, and TextRuleCondition.ConditionType will indicate olConditionSubject.

请注意 Rules 对象模型维护部分奇偶校验与规则和通知向导。Note that the Rules object model maintains partial parity with the Rules and Alerts Wizard. 这意味着时可以使用该向导来创建在向导中指定任何操作,您看到的条件的规则,您可以编程方式创建使用某些规则而不是所有这些操作和条件。This means that while you can use the Wizard to create rules that specify any action and condition that you see in the Wizard, you can programmatically create rules that use some but not all of these actions and conditions. Rules 对象模型支持由向导创建的规则,但不能对那些通过对象模型创建的条件的示例的特定敏感度级别的邮件。An example of a condition that the Rules object model supports for rules created by the Wizard but not for those created by the object model is messages of certain level of sensitivity. 您可以使用向导来创建规则指定为条件的敏感度。You can use the Wizard to create a rule specifying sensitivity as a condition.

使用规则对象模型,可以枚举这种类型的规则集合中每个规则的规则集合-中的规则、 枚举其RuleConditions集合并查找已启用的规则条件的敏感度。Using the Rules object model, you can enumerate this kind of rule in the Rules collection - for each rule in the Rules collection, enumerate its RuleConditions collection and look for an enabled rule condition for sensitivity. 在代码中,这意味着的规则集合中每个规则,枚举**RuleConditions.Item(Index)** 使用_索引_从 1 到**RuleConditions.Count** 和查找与**启用条件RuleCondition.ConditionType** 等于olConditionSensitivityIn code, this would mean for each rule in the Rules collection, enumerate RuleConditions.Item(Index) using the Index from 1 to RuleConditions.Count and look for an enabled condition with RuleCondition.ConditionType equal to olConditionSensitivity. 您还可以启用或禁用在规则中这样的规则条件。You can also enable or disable such a rule condition in a rule. 但是,不能以编程方式创建指定olConditionSensitivity条件的规则。However, you cannot programmatically create a rule that specifies the olConditionSensitivity condition.

下表列出了支持的规则和通知向导中的所有规则条件以及时使用的规则对象模型创建规则是否支持每个规则条件。The following table lists all the rule conditions supported by the Rules and Alerts Wizard, and whether each rule condition is supported when creating a rule using the Rules object model. 仅支持编程枚举由 Rules 对象模型创建的规则中不支持的规则条件以及启用或禁用现有规则中创建的规则和通知向导。A rule condition that is not supported in rules created by the Rules object model is supported only for programmatic enumeration and enabling or disabling in existing rules created by the Rules and Alerts Wizard. 表还显示的规则条件是否适用于olRuleReceive规则类型或olRuleSend规则类型使用的规则。The table also shows whether the rule condition applies to rules with the olRuleReceive rule type or olRuleSend rule type, or both.

注释 您不能启用或禁用类型olConditionOtherMachine规则条件。Note You cannot enable or disable a rule condition of the type olConditionOtherMachine. 此类规则条件指示规则只能在特定计算机上运行,但当前的计算机不是该计算机。This type of rule condition indicates that the rule can run only on a certain computer, but the current computer is not that computer. 一台计算机上创建规则和启用规则条件olConditionLocalMachineOnly ,则指示可以仅在该计算机上运行的规则时,将发生这种情况。This happens when the rule is created on one computer and the rule condition olConditionLocalMachineOnly is enabled, indicating that the rule can run only on that computer. 在某些情况下,如果启用另一个规则条件(如, olConditionAccount),则会自动设置 olConditionLocalMachineIn certain cases, olConditionLocalMachine is automatically set as a result of enabling another rule condition such as olConditionAccount. 当您在另一台计算机上运行相同的规则时,该规则将显示启用了条件olConditionOtherMachineWhen you run the same rule on another computer, the rule will show that the condition olConditionOtherMachine is enabled.

ConditionCondition olRuleConditionType 中的常量Constant in olRuleConditionType 以编程方式创建新规则时是否受支持?Supported when creating new rules programmatically? 是否适用于 olRuleReceive 规则?Apply to olRuleReceive rules? 是否适用于 olRuleSend 规则?Apply to olRuleSend rules?
帐户是在**AccountRuleCondition.Account** 中指定的帐户。Account is the account specified in AccountRuleCondition.Account. olConditionAccountolConditionAccount Yes Yes Yes
为邮件分配了类别。Message is assigned any category. olCondtionAnyCategoryolCondtionAnyCategory Yes Yes Yes
正文包含**TextRuleCondition.Text** 中指定。Body contains words specified in TextRuleCondition.Text. olConditionBodyolConditionBody Yes Yes Yes
正文或主题包含指定单词TextRuleCondition.Text。Body or subject contains words specified by TextRuleCondition.Text. olConditionBodyOrSubjectolConditionBodyOrSubject Yes Yes Yes
邮件分配或多个在**CategoryRuleCondition.Categories** 中指定的类别。Message is assigned the category or categories specified in CategoryRuleCondition.Categories. olConditionCategoryolConditionCategory Yes Yes Yes
邮件抄送框中有我的姓名。Message has my name in the Cc box. olConditionCcolConditionCc Yes Yes
在 x 和 y 之间收到邮件,其中 x 和 y 是整数值。Message was received between x and y, where x and y are Integer values. olConditionDateRangeolConditionDateRange No Yes Yes
将邮件标记为需执行指定操作。Message is flagged for the specified action. olConditionFlaggedForActionolConditionFlaggedForAction No Yes Yes
邮件使用**FormNameRuleCondition.FormName** 中指定的表单。Message uses the form specified in FormNameRuleCondition.FormName. olConditionFormNameolConditionFormName Yes Yes Yes
发件人**出现在 ToOrFromRuleCondition.Recipients** 中指定的收件人列表中。Sender is in the recipient list specified in ToOrFromRuleCondition.Recipients. olConditionFromolConditionFrom Yes Yes No
邮件从任何 RSS 订阅生成。Message is generated from any RSS subscription. olCondtionFromAnyRssFeedolCondtionFromAnyRssFeed Yes Yes No
邮件从指定的 RSS 订阅生成。Message is generated from a specified RSS subscription. olCondtionFromRssFeedolCondtionFromRssFeed Yes Yes No
邮件包含附件。Message has an attachment. olConditionHasAttachmentolConditionHasAttachment Yes Yes Yes
用指定的重要性级别对邮件进行了标记。Message is marked with the specified level of importance. olConditionImportanceolConditionImportance Yes Yes Yes
规则只能在此计算机上运行。Rule can run only on this machine. olConditionLocalMachineOnlyolConditionLocalMachineOnly Yes Yes Yes
邮件是会议邀请或更新。Message is a meeting invitation or update. olConditionMeetingInviteOrUpdateolConditionMeetingInviteOrUpdate Yes Yes Yes
邮件头包含TextRuleCondition.Text中指定。Message header contains words specified in TextRuleCondition.Text. olConditionMessageHeaderolConditionMessageHeader Yes Yes No
消息框中没有我的姓名。Message does not have my name in the To box. olConditionNotToolConditionNotTo Yes Yes No
仅将邮件发送给我。Message is sent only to me. olConditionOnlyToMeolConditionOnlyToMe Yes Yes No
邮件是外出时自动发送的邮件。Message is an out-of-office message. olConditionOOFolConditionOOF No Yes No
规则只能在特定计算机上运行,但不是当前计算机。Rule can run only on a specific machine that is not the current one. olConditionOtherMachineolConditionOtherMachine No Yes Yes
文档属性恰好是或者包含或不包含指定的属性。Document property is exactly, contains, or does not contain specified properties. olConditionPropertyolConditionProperty No Yes Yes
收件人地址包含TextRuleCondition.Text中指定。Recipient address contains words specified in TextRuleCondition.Text. olConditionRecipientAddressolConditionRecipientAddress Yes Yes Yes
发件人地址包含TextRuleCondition.Text中指定。Sender address contains words specified in TextRuleCondition.Text. olConditionSenderAddressolConditionSenderAddress Yes Yes No
发件人位于在**AddressRuleCondition.Address** 中指定的地址列表。Sender is in the address list specified in AddressRuleCondition.Address. olConditionSenderInAddressBookolConditionSenderInAddressBook Yes Yes No
使用指定的敏感度级别对邮件进行了标记。Message is marked with the specified level of sensitivity. olConditionSensitivityolConditionSensitivity No Yes Yes
发送给收件人 (抄送) 将出现在 ToOrFromRuleCondition.Recipients中指定的收件人列表中。Sent to recipients (To, Cc) are in the recipient list specified in ToOrFromRuleCondition.Recipients. olConditionSentToolConditionSentTo Yes Yes Yes
邮件大小是之间 x 和 y 单位 KB,其中 x 和 y 是日期值。Message size is between x and y in units of KB, where x and y are Date values. 例如,"10; 50"设置的大小之间 10 到 50 KB 条件。For example, "10;50" sets the size condition between 10 and 50KB. olConditionSizeRangeolConditionSizeRange No Yes Yes
主题包含TextRuleCondition.Text中指定。Subject contains words specified in TextRuleCondition.Text. olConditionSubjectolConditionSubject Yes Yes Yes
框中有我的姓名。My name is in the To box. olConditionToolConditionTo Yes Yes No
邮件抄送框中有我的姓名。Message has my name in the To or Cc box. olConditionToOrCcolConditionToOrCc Yes Yes No
不识别的规则条件。Unrecognized rule condition. olConditionUnknownolConditionUnknown No Yes No

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.