Do you want to automatically download and save attachments when you receive new emails on Microsoft Outlook to a certain folder? Well, if you ever wondered how, this post will show you how to download Outlook attachments automatically as soon as you receive them. To do that, we will create and configure a VBA script in Outlook.
Automatically download & save Outlook attachments to a certain folder
If you want to automatically download or save attachments from Outlook to a certain folder, you must use a VBA script. There are two main steps involved:
- Create a VBA script.
- Set up an Outlook rule for the created VBA script.
1] Create a VBA script
You can save all your Outlook attachments like word documents, presentations, spreadsheets, PDFs, images, and more to a pre-specified location by using a simple VBA script. VBA stands for Visual Basic for Application which is widely used for creating programs. It runs as an internal programming language in various Microsoft Office applications including MS Outlook. You can create a macro or script through it and further extend the functionalities of your Office apps. Using it, you can also make Outlook save your attachments automatically. However, you will also need to set up an Outlook rule later to run the generated script.
To create the required VBA script, you can follow the below steps:
First of all, open the Outlook app and press the Alt + F11 hotkey to quickly open the Microsoft Visual Basic for Applications window where you will be needed to enter the programming code and create a script.
Now, press the Insert menu from the top menubar and then choose the Module option. This will open a new module window.
After that, copy and paste the below VBA script in the newly opened module window:
Public Sub SaveAttachmentsToDisk(MItem As Outlook.MailItem) Dim oAttachment As Outlook.Attachment Dim sSaveFolder As String sSaveFolder = "C:\Users\Komal\Documents\Outlook" For Each oAttachment In MItem.Attachments oAttachment.SaveAsFile sSaveFolder & oAttachment.DisplayName Next End Sub
Do note that in the above code, “C:\Users\Komal\Documents\Outlook” is the path of the folder where you want the Outlook attachments to be stored automatically. So, replace it with the full path of the corresponding folder on your PC.
Once you have entered the above VBA code correctly, save the script and close the window.
See: Attachment Size Limits for Outlook, Gmail, Yahoo, Hotmail, etc.
2] Set up an Outlook rule for the created VBA script
When you are done creating the above VBA script, second and the last step is to configure an Outlook rule to be able to automatically download and save attachments from Outlook to a specific folder. Here are the steps to do that:
After closing the VBA window, you will be navigated to the Outlook mail view. From here, go to the Home tab and then click on the Rules option.
From appeared options, choose the Manage Rules & Alerts option.
Now, in the newly opened window, tap on the New Rule button present inside the E-mail Rules tab.
In the Rules Wizard window, select the Apply rule on messages I receive option and press the Next button.
On the next screen, uncheck all the checkboxes except for which has an attachment option, and press the Next button. You will then be prompted with a “This rule will be applied to every message you receive. Is this correct?” dialog. Simply tap on the Yes button in this dialog.
Next, tick the run a script checkbox in What do you want to do with the message dialog and then click on the “a script” option. After that, choose the VBA script you just created above and then hit the OK > Next button.
Now, enter the name of the rule and set up rule options including Run this rule now on messages already in “Inbox”, Turn on this rule, and Create this rule on all accounts.
Finally, review the newly created Outlook rule and press the Finish button. Outlook attachments will now be downloaded automatically to your specified folder.
Read: Cannot attach files to email in Outlook.com or Desktop app.
Note: The Run a script option is missing from the recent versions of Microsoft Outlook. However, you can still do a minor Registry tweak to use this option. After making the required Registry changes, you can follow all the above steps to configure the Outlook rule and run the VBA script to automatically download Outlook attachments.
Before making any changes to your Registry, it is highly recommended to create a backup of the Registry. A wrong tweak can severely damage your system. So, be on the safe side by backing up your Registry.
Here is how you can run the created VBA script in Outlook using Registry Editor:
Firstly, open the Registry Editor app. To do that, evoke the Run command box using Win+R and enter regedit in it. Next, in Registry Editor, navigate to the below location:
Computer\HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Security
Now, right-click on the empty section on the right-side panel and choose the New > DWORD (32-bit) Value option from the appeared context menu. Simply name the newly created DWORD as EnableUnsafeClientMailRules.
Next, double-click on the EnableUnsafeClientMailRules DWORD and then enter 1 under the Value data field, and press the OK button.
You will now be able to use the Run a script rule in Outlook.
Read: Block downloading Outlook Calendar attachments automatically.
How do I stop Outlook from automatically downloading attachments?
If you don’t want to download Outlook pictures automatically, open Outlook and click on the File menu. Now, go to Options, navigate to the Trust Center tab, and select the Trust Center Settings option. In the new dialog box, move to the Automatic Download tab and tick the Don’t download pictures automatically in standard HTML email messages or RSS items.
How do I download multiple attachments at once?
To save all attachments from an email at once in MS Outlook, open the email in a separate window and then tap on the drop-down button present next to an attachment. After that, click on the Select All option. Next, click on the Save as button and then browse and select the location where you want to save the attachments. It will then download and save multiple attachments at once.