Class RuleCondition (Outlook VBA)

The RuleCondition object represents either a condition that must be met before a rule executes, or an exception condition that must not be met before a rule executes. To use a RuleCondition class variable it first needs to be instantiated, for example


Dim rcn as RuleCondition
Set rcn = Session.DefaultStore.GetRules(1).Exceptions(Index:=1)

For Each

Here is an example of processing the RuleCondition items in a collection.


Dim rcnCondition As RuleCondition
For Each rcnCondition In Session.DefaultStore.GetRules(1).Conditions
	
Next rcnCondition

Class

Returns an OlObjectClass constant indicating the object's class. Here you can find possible values for OlObjectClass.


Dim oocsClass As OlObjectClass
oocsClass = Session.DefaultStore.GetRules(1).Exceptions(1).Class

ConditionType

Returns a constant in the OlRuleConditionType enumeration that indicates the type of condition for the RuleCondition object. Here you can find possible values for OlRuleConditionType.

For more information on the rule conditions supported for programmatic rule creation, those supported for rules for receiving message, and those supported for rules for sending messages, see Specify Rule Conditions.


Dim orcConditionType As OlRuleConditionType
orcConditionType = Session.DefaultStore.GetRules(1).Exceptions(1).ConditionType

Enabled

Returns or sets a Boolean that determines if the RuleCondition is enabled.

After you enable a rule condition, you must also save the rule by using Rules.Save so that the rule condition and its enabled state will persist beyond the current session. A rule condition is only enabled after it has been saved successfully. Returns an error if you attempt to enable a rule condition that is supported only on a rule of type olRuleSend for a rule of type olRuleReceive, or vice versa. For more information on suppport by rules for receiving messages or rules for sending messages, see Specify Rule Conditions. You cannot enable or disable a condition of type olConditionOtherMachine. This type of rule condition indicates that the rule can run only on a specific computer that is not the current one. This happens when the rule is created on that computer and the rule condition olConditionLocalMachineOnly is enabled, indicating that the rule can run only on that computer. When you run the same rule on another computer, the rule will show that the condition olConditionOtherMachine is enabled. Returns an error if you attempt to enable an exception condition of type olConditionLocalMachineOnly.


Session.DefaultStore.GetRules(1).Exceptions(1).Enabled = True

Session

Returns the NameSpace object for the current session.

The Session property and the GetNamespace method can be used interchangeably to obtain the NameSpace object for the current session. Both members serve the same purpose. For example, the following statements perform the same function: