Applying message rules to the Junk E-mail folder

When you’ve created a rule to directly delete the most obvious spam messages, rather than letting them go to the Junk E-mail folder, you might have noticed that this method isn’t always successful.

This is because once a message has been marked as Junk via the Junk E-mail Filter, no rules will be executed for that message. The reasoning behind this is to prevent it from being moved out of the folder again or to have any other undesirable action being executed because of it (like auto-replying to it).

While you could still manually execute your anti-Junk rules against the Junk E-mail folder to speed up your reviewing process, it is a quite cumbersome process to get to the option and select the rules to execute.

With the VBA macro from this guide, you can execute all your anti-Junk E-mail rules against your Junk E-mail folder with a single click.


Run rules manually

Before getting to the automated VBA solution, let’s quickly look at what it takes to do it manually.

  1. Open the “Manage Rules & Alerts” dialog
    • Outlook 2007
      Tools-> Rules and Alerts…
    • Outlook 2010 ad Outlook 2013
      File-> Manage Rules and Alerts
  2. Click on the button: Run Rules Now…
  3. Locate and select your anti-Junk rules.
  4. Select the Junk E-mail folder.
  5. Click Run Now.

Even if you have only 1 anti-Junk rule and are already in the Junk E-mail folder, that is still at least 6 clicks and 3 different screens/dialogs you have to deal with. So Junk E-mail is still wasting your time!

Running your own Junk Filtering rules is quite cumbersome.
Running your own Junk Filtering rules is quite cumbersome.

RunAllJunkRules VBA macro

The RunAllJunkRules macro automates the above process and will run all rules which have the word “Junk” in them (case insensitive).

There is not even a need to select your Junk E-mail folder first or to have the ruled enabled in your list of rules (which means that it won’t count for your Exchange rule limit either).

Outlook will let you know when it is done executing the rules against your Junk E-mail folder and will display an overview of the executed rules.

Quickly clean up your Junk E-mail with the RunAllJunkRules macro.
Quickly clean up your Junk E-mail with the RunAllJunkRules macro.

Note:
Only Outlook 2007 and later versions of Outlook are supported since programmatic support for executing rules was first introduced in Outlook 2007.
The RunAllJunkRules macro below is based on the RunAllInboxRules code sample by former Outlook MVP Sue Mosher.

Quick Install

Use the following instructions to configure the macro in Outlook;

  1. Download this code-file (runalljunkrules.zip) or copy the code below.
  2. Open the VBA Editor (keyboard shortcut ALT+F11)
  3. Extract the zip-file and import the RunAllJunkRules.bas file via File-> Import…
    If you copied the code, paste it into a new module.
  4. Add a button for easy access to the macro.
  5. Sign your code.

Add a button to the Ribbon or the QAT to run all your Junk E-mail rules.
Add a button to the Ribbon or the QAT to run all your Junk E-mail rules.

Macro Code

The following code is contained in the zip-file referenced in the Quick Install. You can use the code below for review or manual installation.


Click in the area above and press CTR+A to select all. Press CTRL+C to copy the code.