Using the "Rules and Alerts" option to "run a script", the list of scripts to run is empty. What makes a script appear in the list?

The argument must by type MailItem or MeetingItem for the subroutine to be available in the Rules Wizard in Outlook 2007. In Outlook 2010 and 2013, PostItem also works.

You need to avoid processing messages using more than one rule when you are using a run a script rule. Run a script rules should be placed at the top of the rules list and include the "stop processing" action.

All actions should be in the script - don't combine actions in the rule with the run a script rule. Include all of the actions you want to take on the items that meet the rule's conditions in the VBA procedure.

Something like this:

Public Sub ShowMessage(Item As Outlook.MailItem)

'code

End Sub

Using VBA Editor

Open Outlook's VBA editor by pressing Alt+F11 and expand Microsoft Office Outlook Objects then double click on ThisOutlookSession.

Script in the VBA Editor

You'll type or paste the code into the module, then create the rule with the 'run script' Action and select this script

Create a Run a Script Rule

After the script is written, you need to add it to a rule.

  1. Open Rules Wizard. In Outlook 2010 and 2013, it's on Outlook's Home ribbon, 
    Rules > Manage Rules & Alerts. Look on the Tools menu in older versions.
    Open Rules Wizard
  2. Click New Rule.
  3. Select Apply Rule on messages I receive and click Next.
  4. Select your conditions and click Next.
  5. Select Run a script action (near the bottom).
    The finished run a script rule
  6. Click on a script.
    Select the script
  7. Select your script, click OK.
  8. Click Next then finish the rule.

For best results, all actions should be in the script.