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
Using VBA Editor
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.
More Information
- Filter mail when you are not the only recipient
- 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 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
Hello Diane, greetings from Brazil!
We have a doubt in outlook and needs your help:
In my company , we need automate some tasks in Outlook. For example, when we apply some tag in email, we want these email tagged be moved to folder automatically.
I know that outlook web and outlook desktop have rules that i can automate many tasks, like move email to folder from tag, sender, subject, etc, that rules works when emails are sended and received.
I found these manual task in Outlook desktop that move email to folder after i tagged that email manually. In these task, we need click on button "Run Rules Now" manually:
https://filestore.community.support.microsoft.com/api/images/d58b5400-c18c-426d-84fa-0a934716c28e?upload=true
https://filestore.community.support.microsoft.com/api/images/b7a0c5d8-e7e9-41f6-a131-b074cd359483?upload=true
however, in my company we need automate tasks after email arrive in inbox.
This is my doubt: is possible create automatic task for when i apply tag in email received, these email be move to folder automatically? there are script or macro related?
Thanks a lot!!
Mario
hi, i am trying to use "run a script" but in my "Outlook 2019", but that option is missing.
i tried to use the registry hack of "EnableUnsafeClientMailRules" but it also not working. i want to use a way around but for that i need to execute VBA Macro before outlook rules can be run. Can you please guide me on this.
here is my action plan sequence:
Did you restart Outlook after setting the key?
If you ended the registry yourself, try using the exported key from this website.
Hello Brother,
My script is not showing in Run a Script.
Did you put it in ThisOutlookSession? Try putting the script in a new module instead.
The macro 'name' needs to be in this format:
Public Sub ShowMessage(Item As Outlook.MailItem)
Hello, can you please help me with a problem?
I have a rule in Outlook that runs a script, but it suddenly doesn't work anymore. And when I want to change this rule or create a new one I get a message:
"This rule will only be executed when you check your email ..."
Discovered the hard way that if the Sub you are trying to invoke with an Outlook Rule has an Optional parameter, the Rule Editor won't display it for you to select.
I have added script but can't see it in rule page.
The script needs to be named in this format, preferably in a module (not thisoutlooksession) - you don't need to call the mail object Item, but you do need it in the ().
Public Sub ShowMessage(Item As Outlook.MailItem)
It's exactly the opposite. It MUST be in the thisoutlooksession, and CAN'T be in a regular module.
No, it will work in either, but it is recommended to put it in a module. I've had instances where it was not 'seen' if in thisoutlooksession, but none where it was not seen in a module.
how to use in outlook 2016
I'm trying to use the "Send a message to someone when a reminder fires" macro from this page: https://www.slipstick.com/developer/send-email-outlook-reminders-fires/, but it seems like the parameters of that code aren't compatible with what's required for the Rules Wizard to recognize it as a script.