Run all Outlook Rules on Startup

Last reviewed on May 23, 2014

This question from C:

Is there a setting/way to tell Outlook to run all client-only rules on inbox whenever the application is opened. This way when I come in Monday morning and open Outlook, everything will be filed/classified correctly.

Outlook will run all rules that are enabled when messages are downloaded, although, some rules can fail if there are a lot of messages to process (which is not uncommon when starting Outlook after a weekend away). You can use Outlook's Run Rules Now command to run the rules at any time, with Outlook 2010 and up adding a Select All button in the Run Rules Now dialog.

Run all rules now

You can add the Run Rules Now command button to the ribbon or QAT for faster access to the dialog.

If you want something more automatic and are using Outlook 2007 and up, you can run rules using a macro. To run the macro automatically, call the macro from the Application Startup macro, or add it to a button on your ribbon to run it on demand.

Use a macro

Start with the macro from Outlookcode.com, which automates the process of using Run Rules Now, running all rules on the Inbox. As each rule runs, an Outlook dialog box shows you which rule is currently being processed. By adding rl.IsLocalRule = True to the If statement, you can run only the local, or client-side, rules.

The run rules now dialog displays

At the end, a message box displays, letting you know that the macro is finished. This message box can be removed by deleting (or commenting out) each line that references rulelist.

Message box when the macro is finished

If you need help using a macro, information and screenshots are at How to use the VBA Editor

Private Sub Application_Startup()
   RunAllInboxRules
End Sub




Sub RunAllInboxRules()
    Dim st As Outlook.Store
    Dim myRules As Outlook.Rules
    Dim rl As Outlook.Rule
    Dim count As Integer
    Dim ruleList As String
    'On Error Resume Next
     
    ' get default store (where rules live)
    Set st = Application.Session.DefaultStore
    ' get rules
    Set myRules = st.GetRules
     
    ' iterate all the rules
    For Each rl In myRules
        ' determine if it's an Inbox rule
              If rl.RuleType = olRuleReceive And rl.IsLocalRule = True Then
            ' if so, run it
            rl.Execute ShowProgress:=True
            count = count + 1
            ruleList = ruleList & vbCrLf & rl.Name
        End If
    Next
     
    ' tell the user what you did
    ruleList = "These rules were executed against the Inbox: " & vbCrLf & ruleList
    MsgBox ruleList, vbInformation, "Macro: RunAllInboxRules"
     
    Set rl = Nothing
    Set st = Nothing
    Set myRules = Nothing
End Sub

More Information

IsLocalRule property (MSDN)
OL2007+: Run all rules against inbox (OutlookCode.com)
Description of programming with Outlook rules (MSKB) This was written for older versions of Outlook, however, most of the techniques will work in all versions.
How to create a custom rule using Visual Basic for Applications (VBA) in Outlook 2002

Written by

Diane Poremsky
A Microsoft Outlook Most Valuable Professional (MVP) since 1999, Diane is the author of several books, including Outlook 2013 Absolute Beginners Book. She also created video training CDs and online training classes for Microsoft Outlook. You can find her helping people online in Outlook Forums as well as in the Microsoft Answers and TechNet forums.

Please post long or more complicated questions at Outlookforums.

8 responses to “Run all Outlook Rules on Startup”

  1. Gary Ricks

    Diane -

    We have several large group email boxes at our company.

    Based on your comment below - I think some of our rules are not being completed:

    "Outlook will run all rules that are enabled when messages are downloaded, although, some rules can fail if there are a lot of messages to process (which is not uncommon when starting Outlook after a weekend away). "

    We have all of our rules based on when the email comes into the box - we have 7 rules that process and find certain domains on emails - and move those emails based on the domain name. There could be 20 or 30 domains to check for each rule.

    We receive in excess of 200-300 emails a day in each box -

    Would VBA handle the volume better?

    Thanks.

  2. Asusmin

    Hey Diane,

    Thanks, it works like a charm. But how could I run the rules for unread items only? That would make things faster ya?

    Cheers..!!

  3. Tony Wagner

    Diane, how can I trigger an event when an email is selected/displayed in the Reading Pane? I simply want to query the email's Subject Line and take an action if a specific string is found in the Subject Line. Thank you,

Leave a Reply

If the Post Coment button disappears, press your Tab key.