_Rule.Execute Method

Applies a rule as an one-off operation.

Namespace:  Microsoft.Office.Interop.Outlook
Assembly:  Microsoft.Office.Interop.Outlook (in Microsoft.Office.Interop.Outlook.dll)

Syntax

'Declaration
<DispIdAttribute()> _
Sub Execute ( _
    ShowProgress As Object, _
    Folder As Object, _
    IncludeSubfolders As Object, _
    RuleExecuteOption As Object _
)
'Usage
Dim instance As _Rule
Dim ShowProgress As Object
Dim Folder As Object
Dim IncludeSubfolders As Object
Dim RuleExecuteOption As Object

instance.Execute(ShowProgress, Folder, _
    IncludeSubfolders, RuleExecuteOption)
[DispIdAttribute()]
void Execute(
    Object ShowProgress,
    Object Folder,
    Object IncludeSubfolders,
    Object RuleExecuteOption
)

Parameters

  • ShowProgress
    Type: System.Object

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

  • Folder
    Type: System.Object

    Represents the folder where the rule will be applied.

  • IncludeSubfolders
    Type: System.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
    Type: System.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 _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 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:

Parameter

Default Value

ShowProgress

False

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

Reference

_Rule Interface

_Rule Members

Microsoft.Office.Interop.Outlook Namespace

Other Resources

How to: Execute a Rule Instantly