_Rule.Execute(Object, Object, Object, Object) Method

Definition

Applies a rule as an one-off operation.

public void Execute (object ShowProgress, object Folder, object IncludeSubfolders, object RuleExecuteOption);
Public Sub Execute (Optional ShowProgress As Object, Optional Folder As Object, Optional IncludeSubfolders As Object, Optional RuleExecuteOption As Object)

Parameters

ShowProgress
Object

True to display the progress dialog box when the rule is executed, False to run the rule without displaying the dialog box.

Folder
Object

Represents the folder where the rule will be applied.

IncludeSubfolders
Object

True to apply the rule to subfolders of the folder indicated by the Folder parameter; False to apply the rule only to that folder but not its subfolders.

RuleExecuteOption
Object

Represents whether to apply the rule to read, unread, or all messages in the folder or folders specified by the Folder and IncludeSubfolders parameters.

Remarks

Use Execute(Object, Object, Object, Object) to apply a rule as a one-off operation regardless of whether Enabled is True. Use Rule.Enabled and then Save(Object) if you want to apply the rule consistently and persist the rules beyond the current session.

The parameters to the Execute method are optional. If you do not specify any parameters, the rule will be applied to all messages in the Inbox but not to the subfolders of the Inbox. The default values for the optional arguments are as follows:

ParameterDefault Value
ShowProgressFalse
FolderInbox
IncludeSubfoldersFalse
RuleExecuteOption OlRuleExecuteOption.olRuleExecuteAllMessages

If ShowProgress is True and the user cancels the progress dialog box, rule execution is canceled in the same manner as if the user had canceled rule execution through the Rules and Alerts Wizard. Execute returns an error when the user cancels the progress dialog.

If you plan to show a custom progress user interface instead of using the progress dialog box, you should be aware that there are no events that indicate when rule execution starts and stops.

Applies to