How to set an Outlook rule to download attachments to a folder

Matthew Adams
by Matthew Adams
Windows & Software Expert
Matthew is a freelancer who has produced a variety of articles on various topics related to technology. His main focus is the Windows OS and all the things surrounding it. He is passionate about the...
Affiliate Disclosure
Outlook rule to download attachments to a folder
To fix various PC problems, we recommend DriverFix: This software will keep your drivers up and running, thus keeping you safe from common computer errors and hardware failure. Check all your drivers now in 3 easy steps:
  1. Download DriverFix (verified download file).
  2. Click Start Scan to find all problematic drivers.
  3. Click Update Drivers to get new versions and avoid system malfunctionings.
  • DriverFix has been downloaded by 0 readers this month.

Outlook users often need to download files attached to their emails. So, it would be handy if Outlook automatically downloaded all email attachments of newly received emails. You can configure Outlook to do exactly that with a VBA script and a rule for it.

How can I set up an Outlook rule for downloading attachments?

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 hotkey, which opens the Microsoft Visual Basic window.
  2. Click Insert and Module to open a new module window.VBA window outlook rule download attachments to folder
  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.
  5. Note that the ‘C:\Users\DT168\Documents\outlook-attachments’ path in that script is an example. Replace ‘C:\Users\DT168\Documents\outlook-attachments’ with the full path of the folder to download the attachments to.
  6. Next, save the new script.
  7. Close the VBA Module window.

2. Set up an Outlook rule for the VBA script

  1. To set up an Outlook rule for the download attachment script, click the Rules button.The Rules button outlook rule download attachments to folder
  2. Select Manage Rules & Alerts to open the Rules and Alerts window.
  3. Click the New Rule button.
  4. Select the Apply rule on message I receive option and click Next to open the window shown directly below. Some users might need to select a Check messages when they arrive option in older Outlook versions.Rules Wizard outlook rule download attachments to folder
  5. Select the run a script check box.
  6. Click a script to open the Select Script window.
  7. Select the download attachment script in the Select Script window, and click the OK button.
  8. Select the Next option.
  9. Enter a title for the rule in the text box on the last Rules Wizard dialog box.
  10. Select the Turn on this rule option.
  11. 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>.
  12. Click the Finish button.

Thereafter, Outlook will automatically download attachments to the folder path included in the script. Then you won’t need to manually download the attachments. Open the folder path specified in the macro in File Explorer to have a look through the attachments.

For any more questions or suggestions, don’t hesitate to reach for the comments section below.


This article covers:Topics:

Leave a comment below!

add a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

MAKE Sure to check the box “notifications for all macros” in the trust center. then when you set up the script in the rule, outlook will ask you to enable macros. After that this option will work.
Thank my colegue who found out this 🙂


I had to add an additional backslash “” to the end of the sSaveFolder string in the VBA code. Change sSaveFolder = “C:UsersDT168Documentsoutlook-attachments” to sSaveFolder = “C:UsersDT168Documentsoutlook-attachments”

1. Press Windows Key+R to open the run command, type regedit and open the registry editor
2. Navigate to HKEY_CURRENT_USERSoftwareMicrosoftOffice16.0OutlookSecurity
3. Look for DWORD: EnableUnsafeClientMailRules and if it is not there, create a new DWORD and name it that.
4. Set the value of it to 1.
5. You may need to restart Outlook, but the option should now be there.

Only problem I’m having now is that when I run the rule nothing happens. It flashes a quick progress bar like it did something and was successful, but no files are downloaded to the folder I designated. I’ve even test sent an email with an attachment and it didn’t work. I can’t find out what’s wrong. Any help is appreciated here.

I don’t understand where #5 should be in outlook or in VBA? I have looked through rules and do not see anything about a script? Of course I could be missing…….