Rules.Create Method
Outlook Developer Reference |
Creates a Rule object with the name specified by
Name
and the type of rule specified by
RuleType
.
Version Information
Version Added: Outlook 2007
Syntax
expression.Create(Name, RuleType)
expression A variable that represents a Rules object.
Parameters
Name | Required/Optional | Data Type | Description |
---|---|---|---|
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. |
Return Value
A Rule object that represents the newly created rule.
Remarks
The
RuleType
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.
Example
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 |
---|
|
See Also