This applies to Outlook 2010 and newer, including Outlook 365, 2021, 2019, 2016.
Office users who use run-a-script rules are discovering their scripts are currently disabled (as is Start Application), thanks to a security update. When the update is installed, any existing run-a-script and run application rules will be disabled.
To fix, you need to set the EnableUnsafeClientMailRules value in the registry then restart Outlook.
Outlook 2016 and newer
HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Security
DWORD: EnableUnsafeClientMailRules
Value: 1
Outlook 2013
HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Outlook\Security
DWORD: EnableUnsafeClientMailRules
Value: 1
Outlook 2010
HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Outlook\Security
DWORD: EnableUnsafeClientMailRules
Value: 1
If you don't want to edit the registry yourself, you can use this ready-to-use .reg file.
Outlook 2016/2019/2021/365 Outlook 2013
Outlook 2010
One option is to convert the run-a-script to an ItemAdd macro. Depending on the conditions in your rule, converting it to an ItemAdd macro may be as simple as adding the application startup macro, renaming the script, and adding an If statement. For information on using ItemAdd macros, see How to use an ItemAdd Macro.
Hello Diane, for some reason run script is not showing even if I put 1 or 2 in the value (I have Office 365) in the specified Registry path. What could be the reason?
To add a folder in my hard disk I edited the registry then the Script editor is not saving any data and showing as empty ?
I ran the following code in the script editor
kinldy advise
Sub saveAttachments(Item As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
Dim dateFormat
dateFormat = Format(Now, "yyyy-mm-dd H-mm-ss")
saveFolder = "C:\Attachments\" & Item.SenderEmailAddress & " " & dateFormat"
If Not objFSO.FolderExists(saveFolder) Then
objFSO.CreateFolder saveFolder
End If
For Each objAtt In Item.Attachments
objAtt.SaveAsFile saveFolder & "\" & objAtt.DisplayName
Set objAtt = Nothing
Next
End Sub
I AM UNABLE TO SELECT SCRIPTS AFTER SELECTING RUN A SCRIPT
The box with the scripts is empty?
Did you format the script name properly? You need something in the () - example: sub scriptname (item as mailitem)
Yes, The box with the scripts is empty. Below script is saved in text format on my desktop folder in .txt file.
Public Sub SaveAttachmentsToDisk(MItem As Outlook.MailItem)
Dim oAttachment As Outlook.Attachment
Dim sSaveFolder As String
sSaveFolder = ""
For Each oAttachment In MItem.Attachments
oAttachment.SaveAsFile sSaveFolder & oAttachment.DisplayName
Next
End Sub
Thank you! it worked
I need to forward the emails received in a certain mail box to one of the sendor mentioned in the To addresses field, what rule or script should I reply
Will there be more than one address in the To field?
This page has samples, but will need to be tweaked if forwards go to different people each time.
https://www.slipstick.com/outlook/rules/run-script-rule-change-subject-message/
I had my pc rebuilt and have allowed unsafe rules. The rule will move a file to a folder but doesn't run the script, no error message. Macros have been allowed etc.
So you have the rule moving it then running a script? You should only use conditions in the rule - actions should be in the script.
Yes, I found the reason I had copied all the rules from a text file which still had a title in it above the scripts that prevented it working. All good now thanks.
Just sharing this. You can do very cool things with this!
Execute PowerShell Scripts from Your Smartphone | Dmitry's Blog: Cloud, PowerShell and beyond (wordpress.com)
My organisation doesn't allow to set this in registry.
Is there any other workaround for this?
I want to save an attachment from a mail which I receive daily to a folder on a network drive folder.
Please help!
No, there is no other way if you can't run scripts. Sorry.
If you have access to powershell you can try :
if((Test-Path -LiteralPath "HKCU:\SOFTWARE\Microsoft\Office\16.0\Outlook\Security") -ne $true) { New-Item "HKCU:\SOFTWARE\Microsoft\Office\16.0\Outlook\Security" -force -ea SilentlyContinue };
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Microsoft\Office\16.0\Outlook\Security' -Name 'EnableUnsafeClientMailRules' -Value 1 -PropertyType DWord -Force -ea SilentlyContinue
any idea why its called EnableUnsafeClientMailRules
What exactly is unsafe about it
It is disabled because it can do things outside of outlook (start application is disabled too). While it is hard to install an outlook macro, there was an exploit that used run application.
Detect and remediate the Outlook rules and custom forms injections attacks. - Office 365 | Microsoft Docs
Thank you for your quick response