• Outlook User
  • New Outlook app
  • Outlook.com
  • Outlook Mac
  • Outlook & iCloud
  • Developer
  • Microsoft 365 Admin
    • Common Problems
    • Microsoft 365
    • Outlook BCM
    • Utilities & Addins

Run all Outlook Rules on Startup

Slipstick Systems

› Outlook › Rules, Filters & Views › Run all Outlook Rules on Startup

Last reviewed on September 16, 2019     26 Comments

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)

Run all Outlook Rules on Startup was last modified: September 16th, 2019 by Diane Poremsky

Related Posts:

  • Run Rules Now using a Macro
  • Running Rules on messages after you read them
  • Enable or Disable an Outlook Rule using Reminders
  • Creating an AND rule in Outlook Rules

About 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.

Subscribe
Notify of
26 Comments
newest
oldest most voted
Inline Feedbacks
View all comments

Lawrence Scheeler
July 2, 2020 5:01 pm

This is what I was looking for but it fails when I run it on Outlook 365/2016, Win10, 64-bit for both Win and Office. It fails on
Set myRules = st.GetRules

What does that do and how do I fix it? All my rules are Client rules.

0
0
Reply
Jay
September 18, 2018 7:20 pm

Hi,
I've been using this for years and it is great! My laptop was just upgraded to Win10, when I added this code, I keep getting a Run-time error - Automation Error. When I debug, it highlights Line 27 "Next". Any thoughts?

(Outlook 2016 64-Bit; Win 10 64-Bit)

0
0
Reply
Diane Poremsky
Author
Reply to  Jay
September 19, 2018 11:38 pm

It's not Win10... and it's not Outlook 64-bit. (I use both and the macro works.)
What type of email account? POP, IMAP, Exchange/Outlook.com?

0
0
Reply
Jay
Reply to  Diane Poremsky
August 6, 2019 7:10 pm

Sorry for the delay, thought I'd take another stab at this...On-Premise Exchange.

0
0
Reply
Aziz Semaan
March 21, 2017 10:49 am

hi

i have multiple exchange accounts with rules (server side rule) how can i modify the code to run on a specific account(s)

0
0
Reply
Diane Poremsky
Author
Reply to  Aziz Semaan
March 23, 2017 1:54 pm

You need to either walk all stores or identify a specific store - this calls the default store:
Set st = Application.Session.DefaultStore
The macro at https://www.slipstick.com/developer/get-color-categories-and-restore-them-using-vba/#stores shows how to walk the stores.

0
0
Reply
Jeremy Ng
February 13, 2017 3:30 am

Hi,
Thanks for the code. I tried it but it didnt work, I changed this statement to False and it worked.

If rl.RuleType = olRuleReceive And rl.IsLocalRule = False

Thanks, will monitor what it will does to the mail. Thank you.

0
0
Reply
Diane Poremsky
Author
Reply to  Jeremy Ng
February 14, 2017 1:27 am

Do you have an exchange account? True = client side rule, False = server side rule.

0
0
Reply
Jeff
December 9, 2016 1:55 pm

`Hello,

Does this macro runs for all the email has been defined to my outlook? Currently I have 2-3 email defined to my outlook, or just runs for the Default email address?
Regards,
Jeff Paarsa

0
0
Reply
Diane Poremsky
Author
Reply to  Jeff
February 14, 2017 1:28 am

this: Set st = Application.Session.DefaultStore tells it to use the rules in the default store, so no, it doesn't as written. It would be possible to add a loop to cover all data file stores.

0
0
Reply
Denise
Reply to  Diane Poremsky
February 27, 2017 2:03 pm

I would like for it to run the rules for the secondary email attached to my account and not the default account. How would the code change for that (the loop that you mention above)?

0
0
Reply
Diane Poremsky
Author
Reply to  Denise
June 3, 2017 12:01 am

What type of email accounts do you use? If it has its own message store then you need to find that store. The macro at https://www.slipstick.com/developer/get-color-categories-and-restore-them-using-vba/#stores shows how to loop the stores - use an if statement to select the store you want to use.

POP and IMAP accounts may store runs in the default data file - in that case, you would set the account in the rule.

0
0
Reply
Ron
October 29, 2015 11:51 am

I'd like to use this code to show a text dump of all my session's Rules instead of the Execute(), but I just get lots of "type Mismatch" and "Object does not support this method or property" errors when trying to use the Actions and Conditions collections. Could someone show me how to do this please? Thanks

0
0
Reply
Diane Poremsky
Author
Reply to  Ron
October 29, 2015 12:43 pm

See https://www.slipstick.com/outlook/rules/create-list-rules/ for a code sample. It won't get every rule condition or action though - i only added some as an example.

0
0
Reply
Diane Poremsky
Author
Reply to  Diane Poremsky
October 29, 2015 1:04 pm

This code should print a user-friendly list print a list of rules

0
0
Reply
Giandomenico Plaino (@plao68)
October 29, 2015 7:03 am

Thanks Diane!!! Great great piece of code... :-)

0
0
Reply
Tony Wagner
September 16, 2014 12:53 pm

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,

0
0
Reply
Diane Poremsky
Reply to  Tony Wagner
September 16, 2014 1:24 pm

You'd need to use ActiveExplorer.Selection.Item(1) to get the currently selected item.

Like this:
Set objItem = objApp.ActiveExplorer.Selection.Item(1)

But, it might be better to use itemadd or a run a script rule so its processed as it arrives. If you want to process it after the fact you can use a macro (click a button to run it) or a macro that is triggered when you either do something (set a category or flag work good) or just select the message.

Private WithEvents Items As Outlook.Items

Private Sub Application_Startup()
Dim Ns As Outlook.NameSpace

Set Ns = Application.GetNamespace("MAPI")
Set Items = Ns.GetDefaultFolder(olFolderInbox).Items
End Sub

Private Sub Items_ItemChange(ByVal Item As Object)
' do whatever
end sub

0
0
Reply
Tony Wagner
Reply to  Diane Poremsky
September 16, 2014 7:09 pm

I'm not looking for an action to take place when the email arrives. I'm looking to trigger an action when I select the email to be displayed in the Reading Pane. Is something like that possible? Thanks, Diane!

0
0
Reply
Diane Poremsky
Reply to  Tony Wagner
September 16, 2014 8:27 pm

you'll use selectionchange for that - this goes in ThisOutlookSession.

Public WithEvents myOlExp As Outlook.Explorer

Public Sub Initialize_handler()
Set myOlExp = Application.ActiveExplorer
End Sub

Private Sub myOlExp_SelectionChange()
MsgBox myOlExp.Selection.Count & " items selected."
End Sub

0
0
Reply

Visit Slipstick Forums.
What's New at Slipstick.com

Latest EMO: Vol. 30 Issue 36

Subscribe to Exchange Messaging Outlook






Support Services

Do you need help setting up Outlook, moving your email to a new computer, migrating or configuring Office 365, or just need some one-on-one assistance?

Our Sponsors

CompanionLink
ReliefJet
  • Popular
  • Latest
  • Week Month All
  • Use Classic Outlook, not New Outlook
  • How to Remove the Primary Account from Outlook
  • Reset the New Outlook Profile
  • This operation has been cancelled due to restrictions
  • Disable "Always ask before opening" Dialog
  • Adjusting Outlook's Zoom Setting in Email
  • How to Hide or Delete Outlook's Default Folders
  • Removing Suggested Accounts in New Outlook
  • Remove a password from an Outlook *.pst File
  • Syncing Outlook with an Android smartphone
  • Opt out of Microsoft 365 Companion Apps
  • Mail Templates in Outlook for Windows (and Web)
  • Urban legend: Microsoft Deletes Old Outlook.com Messages
  • Buttons in the New Message Notifications
  • Move Deleted Items to Another Folder Automatically
  • Open Outlook Templates using PowerShell
  • Count and List Folders in Classic Outlook
  • Google Workspace and Outlook with POP Mail
  • Import EML Files into New Outlook
  • Opening PST files in New Outlook
Ajax spinner

Recent Bugs List

Microsoft keeps a running list of issues affecting recently released updates at Fixes or workarounds for recent issues in classic Outlook (Windows).

For new Outlook for Windows: Fixes or workarounds for recent issues in new Outlook for Windows .

Outlook for Mac Recent issues: Fixes or workarounds for recent issues in Outlook for Mac

Outlook.com Recent issues: Fixes or workarounds for recent issues on Outlook.com

Office Update History

Update history for supported Office versions is at Update history for Office

Outlook Suggestions and Feedback

Outlook Feedback covers Outlook as an email client, including Outlook Android, iOS, Mac, and Windows clients, as well as the browser extension (PWA) and Outlook on the web.

Outlook (new) Feedback. Use this for feedback and suggestions for Outlook (new).

Use Outlook.com Feedback for suggestions or feedback about Outlook.com accounts.

Other Microsoft 365 applications and services




New Outlook Articles

Opt out of Microsoft 365 Companion Apps

Mail Templates in Outlook for Windows (and Web)

Urban legend: Microsoft Deletes Old Outlook.com Messages

Buttons in the New Message Notifications

Move Deleted Items to Another Folder Automatically

Open Outlook Templates using PowerShell

Count and List Folders in Classic Outlook

Google Workspace and Outlook with POP Mail

Import EML Files into New Outlook

Opening PST files in New Outlook

Newest Code Samples

Open Outlook Templates using PowerShell

Count and List Folders in Classic Outlook

Insert Word Document into Email using VBA

Warn Before Deleting a Contact

Use PowerShell to Delete Attachments

Remove RE:, FWD:, and Other Prefixes from Subject Line

Change the Mailing Address Using PowerShell

Categorize @Mentioned Messages

Send an Email When You Open Outlook

Delete Old Calendar Events using VBA

VBA Basics

How to use the VBA Editor

Work with open item or selected item

Working with All Items in a Folder or Selected Items

VBA and non-default Outlook Folders

Backup and save your Outlook VBA macros

Get text using Left, Right, Mid, Len, InStr

Using Arrays in Outlook macros

Use RegEx to extract message text

Paste clipboard contents

Windows Folder Picker

Custom Forms

Designing Microsoft Outlook Forms

Set a custom form as default

Developer Resources

Developer Resources

Developer Tools

VBOffice.net samples

SlovakTech.com

Outlook MVP David Lee

Repair PST

Convert an OST to PST

Repair damaged PST file

Repair large PST File

Remove password from PST

Merge Two Data Files

Sync & Share Outlook Data

  • Share Calendar & Contacts
  • Synchronize two computers
  • Sync Calendar and Contacts Using Outlook.com
  • Sync Outlook & Android Devices
  • Sync Google Calendar with Outlook
  • Access Folders in Other Users Mailboxes

Diane Poremsky [Outlook MVP]

Make a donation

Mail Tools

Sending and Retrieval Tools

Mass Mail Tools

Compose Tools

Duplicate Remover Tools

Mail Tools for Outlook

Online Services

Calendar Tools

Schedule Management

Calendar Printing Tools

Calendar Reminder Tools

Calendar Dates & Data

Time and Billing Tools

Meeting Productivity Tools

Duplicate Remover Tools

Productivity

Productivity Tools

Automatic Message Processing Tools

Special Function Automatic Processing Tools

Housekeeping and Message Management

Task Tools

Project and Business Management Tools

Choosing the Folder to Save a Sent Message In

Run Rules on messages after reading

Help & Suggestions

Submit Outlook Feature Requests

Slipstick Support Services

Buy Microsoft 365 Office Software and Services

Visit Slipstick Forums.

What's New at Slipstick.com

Home | Outlook User | Exchange Administrator | Office 365 | Outlook.com | Outlook Developer
Outlook for Mac | Common Problems | Utilities & Addins | Tutorials
Outlook & iCloud Issues | Outlook Apps
EMO Archives | About Slipstick | Slipstick Forums
Submit New or Updated Outlook and Exchange Server Utilities

Send comments using our Feedback page
Copyright © 2025 Slipstick Systems. All rights reserved.
Slipstick Systems is not affiliated with Microsoft Corporation.

:wpds_smile::wpds_grin::wpds_wink::wpds_mrgreen::wpds_neutral::wpds_twisted::wpds_arrow::wpds_shock::wpds_unamused::wpds_cool::wpds_evil::wpds_oops::wpds_razz::wpds_roll::wpds_cry::wpds_eek::wpds_lol::wpds_mad::wpds_sad::wpds_exclamation::wpds_question::wpds_idea::wpds_hmm::wpds_beg::wpds_whew::wpds_chuckle::wpds_silly::wpds_envy::wpds_shutmouth:
wpDiscuz

Sign up for Exchange Messaging Outlook

Our weekly Outlook & Exchange newsletter (bi-weekly during the summer)






Please note: If you subscribed to Exchange Messaging Outlook before August 2019, please re-subscribe.

Never see this message again.

You are going to send email to

Move Comment