How to Set Outlook Rule Save Email Attachments to a Folder

A VBA script is usually the quickest solution

Reading time icon 3 min. read

Readers help support Windows Report. We may get a commission if you buy through our links. Tooltip Icon

Read our disclosure page to find out how can you help Windows Report sustain the editorial team Read more

Key notes

  • 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.
how to set outlook rule to save attachment

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

  1. 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.
  2. Click Insert and Module to open a new module window.insert
  3. 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
    End Sub
  4. Paste that code into the VBA Module window with the Ctrl + V hotkey.paste
  5. 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.
  6. Next, save the new script.
  7. 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

Note icon NOTE
The option to Run a script has been discontinued in the recent versions of Outlook. You can get it back by making minor changes to the Registry, as illustrated in the first few steps below.
  1. Press Windows + R to open Run, type regedit, and then hit Enter.registry
  2. Click Yes in the UAC prompt.
  3. 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\Securitypath
  4. Right-click on the empty portion, hover the cursor over New, choose DWORD (32-bit) Value, and then name it EnableUnsafeClientMailRules.dword (32-bit) value
  5. Double-click on the newly created DWORD, enter 1 under Value Data, and then click OK to save the changes.value data
  6. Now, launch Outlook.
  7. To set up a rule to download attachments, click the Rules button, and then select Manage Rules & Alerts.manage rules and alerts
  8. Click the New Rule rule
  9. 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.apply rule
  10. Choose the which has an attachment option, and then click Next.rule
  11. Select the Run a script check box, and then under Step 2, click on a script a script
  12. Select the download attachment script you pasted earlier, and then click the OK button.script
  13. Click Next.
  14. Enter a title for the rule in the text box, and select the Turn on this rule option.
  15. 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>.
  16. 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.

More about the topics: email, Outlook Guides