Yesterday I published a post about Taming Outlook meeting requests, in which I talked through the writing of a script which checked for working hours and calendar availability, before automatically accepting any meeting which met the requirements. And then I left you hanging… Sorry about that!
Well here I am to pick up where I left off. We’re going to look at actually running the script!
First of all, you’ll need to slightly drop your security settings, whilst you’re developing. We’ll come back to fix this at the end, once we’re happy the script is working. The setting I’m referring to can be found in Outlook (I’m using 2016) here…
File > Options > Trust Center > Trust Center Settings > Macro Settings
Hopefully you’ve either got this set to “Disable all…”, which would be the most secure (but possibly a little limiting” or “Notifications for digitally signed…” which is the second most secure. We haven’t digitally signed our script (yet!) so we’ll to set this to “Notifications for all macros”.
Please be careful to only click yes on prompts for this script, or others that you know about, and don’t blame me if you click yes on something dodgy!
Now we need to go and create a new mail rule. This can usually be done by choosing “Rules” from the ribbon menu and then “Create a rule”, but hopefully this is something you’re familiar with, feel free to skip out and Google this is you’re not.
Now you’ve started creating a new rule, you’ll want to select the conditions “on this computer only” (because the script only exists on this computer) and “which is a meeting invitation or update” (so that it doesn’t process your script for every single email, something like this…
Then click the “Next” button and you’ll want to select the action “run a script”. If you’re in a newer version of Outlook (anything from 2013 onwards, I believe) then you may find that you don’t have this option, in which case, you’ll want to add the following registry entry and then restart Outlook…
Entry: HKEY_CURRENT_USERSoftwareMicrosoftOffice16.0OutlookSecurity Dword: EnableUnsafeClientMailRules Value: 1
You can also download the .reg file, if you would like. It should be noted that this is for Outlook 2016, and it might be different (not version 16.0) for other versions.
Once this is down and you’ve restarted, you should be able to select the “run a script” option.
At the bottom you then have a link to click which says “a script”, which will allow you to select the script you’ve written and compiled in part 1.
If you’re following this blog then this is almost certainly going to only give you one script to select, but if not, look for the one that matches the name you used – for me this is “Project1.ThisOutlookSession.AutoAcceptMeetings”, and click “OK”.
You can then complete the wizard, adding an exceptions you want (none for me) and then setting the name (something massively original like “Auto Accept Meetings”) and when it should run, etc.
You can now test, either on existing meeting requests in your inbox, or by waiting for the next one to come in! If you’ve left those Debug.Print lines in then it might be worth hitting Alt+F11 in Outlook to get back to the script editor, and then pressing Ctrl+G in there. This will bring out an “Immediate” panel at the bottom, and this is like a console, which will display all of the debug messages when they happen.
Once you’ve got your script working, it’s time to go back and sort out your security. The way that we do this, is by self signing the script. There are a number of guides online about how to do this, but I’m going to quickly walk you through the steps I took on my Windows 10 machine.
Firstly, find “SelfCert.exe” – this is the Office application that we will be using to create the certificate. For me, this was located here…
C:Program Files (x86)Microsoft OfficeOffice16SELFCERT.EXE
Run this application and it should look like this…
There’s a box at the bottom to enter your certificate name, so just enter whatever you like and click “OK”. You should get a message to say it’s been successfully created.
Now go back into the script editor by pressing Alt+F11 in Outlook, and from the “Tools” menu select the “Digital Signature” menu item. In this screen you can use the “Choose” button to find your certificate and select it, and then click “OK”. That’s it, signed!
Now exit Outlook and run it again “as administrator”. You should then run your rule, manually if it doesn’t happen automatically, and you’ll get a popup asking you if it’s ok to run the macro. Personally I went with “Trust all documents from this publisher”, as I am the publisher, and I trust myself. You can now set your Trust Center settings back, so that only signed macros are prompted for.
You can now exit Outlook and run it again normally. You should have Outlook meeting request bliss now, as your rule will run, which will run your script, and automatically accept all those meetings requests for you. As you’ve trusted yourself, you shouldn’t get any more prompts.
Ahhhh, that’s better!
If you’re interested, you can download the .cls file, which contains all the code.