Muokkaa

Jaa


Rule.Execute method (Outlook)

Applies a rule as a one-off operation.

Syntax

expression. Execute( _ShowProgress_ , _Folder_ , _IncludeSubfolders_ , _RuleExecuteOption_ )

expression A variable that represents a Rule object.

Parameters

Name Required/Optional Data type Description
ShowProgress Optional Boolean True to display the progress dialog box when the rule is executed, False to run the rule without displaying the dialog box.
Folder Optional Folder Represents the folder where the rule will be applied.
IncludeSubfolders Optional Boolean 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 Optional OlRuleExecuteOption 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 Rule.Execute to apply a rule as a one-off operation regardless of whether Rule.Enabled is True. Use Rule.Enabled and then Rules.Save 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 don't 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:

Parameter Default Value
Folder Inbox
IncludeSubfolders False
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.

See also

Rule Object

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.