How to Set Outlook Rule Save Email Attachments to a Folder
A VBA script is usually the quickest solution
- Setting an Outlook rule to save all attachments automatically will greatly increase your productivity.
- In order to do that, you can use the code provided below to create a VBA script.
- You may also set a rule in Outlook to download attachments.
Outlook users often need to download files attached to their emails. And there’s a way you can automatically save email attachments to a folder in Outlook using by setting up a rule.
The ability to automatically download all email attachments of newly received emails in Outlook and save them to folders is handy. So, let’s find out how you can do that with a VBA Script.
How can I set up an Outlook rule to automatically save email attachments to a folder?
1. Set up the VBA script
- First, set up a VBA script that downloads the attachments to a specified folder. Press the Alt + F11 or Alt + Fn + F11 hotkey, depending on whether the function key is locked or unlocked, which opens the Microsoft Visual Basic window.
- Click Insert and Module to open a new module window.
- Copy this VBA code with the Ctrl + C hotkey:
Public Sub SaveAttachmentsToDisk(MItem As Outlook.MailItem)
Dim oAttachment As Outlook.Attachment
Dim sSaveFolder As String
sSaveFolder = "C:\Users\DT168\Documents\outlook-attachments"
For Each oAttachment In MItem.Attachments
oAttachment.SaveAsFile sSaveFolder & oAttachment.DisplayName
Next
End Sub - Paste that code into the VBA Module window with the Ctrl + V hotkey.
- Note that the C:\Users\DT168\Documents\outlook-attachments path in that script is an example. Replace it with the full path of the folder to download the attachments.
- Next, save the new script.
- Close the VBA Module window.
For those wondering how to automatically download/save attachments from Outlook to a certain folder VBA, you now know the script. The next step is to set a rule for it.
2. Set up an Outlook rule for the VBA script
- Press Windows + R to open Run, type regedit, and then hit Enter.
- Click Yes in the UAC prompt.
- Paste the following path ((might be different for other versions of Outlook) in the address bar and hit Enter:
Computer\HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Security
- Right-click on the empty portion, hover the cursor over New, choose DWORD (32-bit) Value, and then name it EnableUnsafeClientMailRules.
- Double-click on the newly created DWORD, enter 1 under Value Data, and then click OK to save the changes.
- Now, launch Outlook.
- To set up a rule to download attachments, click the Rules button, and then select Manage Rules & Alerts.
- Click the New Rule button.
- Select the Apply rule on message I receive option and click Next. Some users might need to select a Check messages when they arrive option in older Outlook versions.
- Choose the which has an attachment option, and then click Next.
- Select the Run a script check box, and then under Step 2, click on a script link.
- Select the download attachment script you pasted earlier, and then click the OK button.
- Click Next.
- Enter a title for the rule in the text box, and select the Turn on this rule option.
- You can also select the Run this rule now on messages already in Inbox option if preferred. The rule description box should read as follows: Apply this rule after the message arrives on this computer only run <macro title>.
- Click the Finish button.
Once done with the rule, Outlook will automatically download attachments to the folder path in the script. Then you won’t need to download the attachments manually. Open the folder path specified in the macro in File Explorer to look through the attachments.
If you are looking for alternatives, here are the best email clients for Microsoft 365.
For any more questions or suggestions, don’t hesitate to reach for the comments section below.