How to Automatically Download/Save Attachments in Outlook to a Certain Folder Using [VBA + Rules]?

Last Updated on August 27, 2022 by Amit Bansal

Imagine you are working on a project, and you received tons of emails related to that project with attachments, and you want to save all the attachments in your computer drive without fail.

Suppose you come after a vacation and your email account is flooded with emails, finding emails with attachments and somehow it is difficult downloading attachments one by one is a real pain.

In this article, you will learn smart solutions to automatically download attachments from Outlook to a certain folder.

Outlook Automatically Save Attachments Using VBA

This method will introduce a VBA script and run this script with a rule to automatically download and save Outlook attachments to a certain folder. Please do as follows:

Step 1: Open Microsoft Outlook

Step 2: Click on Developer >> Visual Basic to open Microsoft Visual Basics.

Use Keyboard Shortcut Alt + F11

Step 3: Click Insert >> Module, which will open the VBA script black page.

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

Step 4: Copy the code with the Ctrl + C hotkey and paste the code with the Ctrl + V hotkey into the script black page.

Note: Please find out C:\Users\DT168\Documents\outlook-attachments\, in the code and replace the destination folder’s path as you need.

You can easily Copy the Full Path of a File on Windows 10.

Step 5: Save the VBA Script and close the Microsoft Visual Basic for Applications window.

That’s the end of one part, now it’s time to follow the second step.

Set up an Outlook rule for the VBA script

Once your VBA code is inserted in Outlook, it’s time to give that life, Using the VBA script under Rule, executed the function and you will get all the attachments to save under a specific folder in Outlook.

Let’s dive in and understand step by step method “How to activate it?”

Step 1: Go to the Home Tab >> Click Rules >> Manage Rules & Alerts, Use Keyboard Shortcut (Alt + H + RR + L).

Step 2: Rules and Alerts dialog box appears, please click the New Rule button on the E-mail Rules tab.

Step 3: Rules Wizard dialog box appears, click below to select the ‘Apply rule on messages I receive‘ option, and click the Next button.

Step 4: Next is which condition you want to check. there are numerous options available in Outlook rules to begin, but in this case, leave every option unchecked.

You get the message “This Rule will be applied to every message you receive, Is this Correct?” Click Yes to process.

Step 5: What do you want to do with the messages, what is the next question you need to select, check the option “run a script“, Click the text of a script to open the Select Script dialog box.

You need to select the script, which is already available in the script box (the code you have added in the Microsoft Visual Basic above).

Click Next.

Step 6: Next is “Are there any exceptions?“, Mostly this part is bypassed, Checkout if you don’t require to put a condition of the exemption and click Next to move forward.

Step 7: Final Rule Wizard setup dialog box appear:

  1. Specify the name of your rule.
  2. Setup rule option.
  3. Review your rule.
  4. Finally, Click Finish.

Note:This rule is only run when you check your email in Outlook. If Outlook isn’t running, this rule won’t work for email you check online or from another device.’

Now, all attachments from your email account are downloaded and saved into the specified destination folder. Incoming email attachments will also be automatically downloaded and saved into the specified folder.

Run-a-Script Missing in Outlook Rule Wizard

Almost every Outlook user encountered this issue “Run-a-Script Missing in Outlook Rule Wizard”

It is especially important to run a script option in your rule wizard to complete the rule.

Due to security updates in current versions of Outlook, “run a script” is disabled. How to re-enable scripts for different versions of Outlook.

To fix this, you need to set the EnableUnsafeClientMailRules value in the registry and then restart Outlook.

Enable Macro Settings

After all the setup you need to check whether your macros are enabled or not: you need to make some changes in Outlook security settings.

Step 1: On the File tab >> Click Outlook Options to open the Outlook Options dialog box.

Step 2: Click Trust Center >> then Click Trust Center Settings.

Step 3: Click the Macro Settings option on the left >> Change/Select the check box “Notification for all macros”.

Step 4: Click Ok to close and activate, this option allows macros to run in Outlook, but before the macro runs, Outlook prompts you to verify that you want to run the macro.

Note: – Restart Outlook for the configuration change to take effect.

Final Words

If you carefully follow the exact steps in the above articles, you will download them. Save all your attachment received with the email in your inbox.

While creating a rule you can modify the rule for emails received in your inbox, for instance, from your boss or from your financial manager.

I personally work as a Project Coordinator, and I use to enable this feature to save attachments of all the emails received of the Project Progress Report.

Finally, I’ve automated the email attachment process. Now, whenever an email attachment arrives, it’s automatically saved to my “specified” folder.

Amit Bansal

Hello, my name is Amit Kumar Bansal, and I am the founder of Through this blog, I focus on Microsoft Outlook, offering insightful and informative content. Additionally, I produce educational videos on YouTube to further enhance the understanding of my audience. visit my YouTube Channel

View all posts

3 thoughts on “How to Automatically Download/Save Attachments in Outlook to a Certain Folder Using [VBA + Rules]?”

  1. Hi,
    Thanks for your article.
    I have followed the steps to make VBA script and then make a new rule using ‘Run a script’ for emails having specific words in subject.
    I tested by running the rule manually via option ‘Run Rules now’. It shows the progress bar for running the rule and finishes without any error but actually attachment is not downloaded. (Attachment is a zip file)
    Can you please advise what may be the reason and how to troubleshoot?
    Thank you.


Leave a Comment