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 (and up), PostItem also works.
Something like this:
Public Sub ShowMessage(Item As Outlook.MailItem) 'code End Sub
Open Outlook's VBA editor by pressing Alt+F11 and expand Microsoft Office Outlook Objects then double click on ThisOutlookSession.
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.
If you have Outlook 2016 and run a script action is missing, see "Run-a-Script Rules Missing in Outlook" for the fix.
- 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.
- Click New Rule.
- Select Apply Rule on messages I receive and click Next.
- Select your conditions and click Next.
- Select Run a script action (near the bottom).
- Click on a script.
- Select your script, click OK.
- Click Next then finish the rule.
For best results, all actions should be in the script.
- Process Mail that was Auto Forwarded by a Rule
- Run a Script: Send Autoreply with Date
- Filter messages containing spam or other words
- Creating an AND rule in Outlook Rules
- Search PDF Attachments and Forward
- Run-a-Script Rules Missing in Outlook
- Blocking Mail From New Top-Level Domains
- How to Process Mail After Business Hours
- Create Appointment From Email Automatically
- Open All Hyperlinks in an Outlook Email Message
- Talking Reminders
- Receive a Reminder When a Message Doesn't Arrive?
- Delegates, Meeting Requests, and Rules
- Run Rules Now using a Macro
- Automatically Add a Category to Accepted Meetings
- Save and Rename Outlook Email Attachments
- Use a Rule to delete older messages as new ones arrive
- Convert RTF Messages to Plain Text Format
- Outlook AutoReplies: One Script, Many Responses
- Use VBA to move messages with attachments
- Save all incoming messages to the hard drive
- Run a script rule: Reply to a message
- Sort messages by Sender domain
- Use a Macro to Copy Data in an Email to Excel
- Save Outlook Email as a PDF