|Outlook Developer Reference|
Creates a Rule object with the name specified by
and the type of rule specified by
Version Added: Outlook 2007
expression A variable that represents a Rules object.
|Name||Required||String||A string identifier for the rule, which will be represented by Rule.Name after rule creation. Names of rules in a collection are not unique.|
|RuleType||Required||OlRuleType||A constant in the OlRuleType enumeration that determines whether the rule is applied on sending or receiving a message.|
A Rule object that represents the newly created rule.
parameter of the added rule determines valid rule actions, rule conditions, and rule exception conditions that can be associated with the Rule object.
When a rule is added to the collection, the Rule.ExecutionOrder of the new rule is 1. The ExecutionOrder of other rules in the collection is incremented by 1.
The following code sample in Visual Basic for Applicatons (VBA) uses the Rules object model to create a rule. The code sample uses the RuleAction and RuleCondition objects to specify a rule that forwards messages from a specific sender to a specific folder, unless the message contains certain terms in the subject. Note that the code sample assumes that there already exists a folder "Dan" under the Inbox.
|Visual Basic for Applications|