Automatically download Outlook attachments

Automatically download Outlook attachments to folder using VBA and Outlook rule

To achieve this automation which automatically download and save Outlook attachments to a chosen folder, you need to create a VBA script and run this script with a rule to. Please do as follows:

  1. Press Alt + F11 keys to open the Microsoft Visual Basic for Applications window.
  2. Click Insert > Module, and then paste below VBA script into the new opening Module window.

VBA: Auto Save Outlook Attachments into a certain folder

          Public Sub SaveOutlookAttachmentsToDisk(MItem As Outlook.MailItem)
Dim oOutlookAttachment As Outlook.Attachment
Dim sSaveAttachmentsFolder As String
sSaveAttachmentsFolder = “ D:\ServerReports\outlook-attachments\
For Each oOutlookAttachment In MItem.Attachments
oOutlookAttachment.SaveAsFile sSaveAttachmentsFolder &                   oOutlookAttachment.DisplayName
Next
End Sub

Note: You can replace the destination folder’s path as you need. Above code looks as

1

Fig.1

 

  1. Save the VBA Script and close the Microsoft Visual Basic for Applications window.
  2. Go to the Mail view, and click Home > Rules > Manage Rules & Alerts. See screenshots:

2

Fig.2

 

3

Fig.3

 

This selection is optional. If you do not wish to download all attachments, you can select conditions from Fig.4.

4

Fig.4

 

5

Fig.5

 

6

Fig.6

 


Unable to see run a script option in outlook?

a. Right Click on desktop (or any desired folder location) New > New text document.
b. Copy – Paste registry code as shown. (Code in text is given below Fig.7)
c. Save as .reg file with the contents below. (You can give any name)

7

Fig.7

 

I. Outlook 2016

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Security]

“EnableUnsafeClientMailRules”=dword:00000001

 

ii. Outlook 2013

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Security]

“EnableUnsafeClientMailRules”=dword:00000001

 

iii. Outlook 2010

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Security]

“EnableUnsafeClientMailRules”=dword:00000001

d. Run the .reg file as an admin

8

Fig.8

 

f. Restart outlook. (Rebooting in case it do not show)


Back to Attachment process.

6
Fig.6 (Repeat)

 

9

Fig.9

 

10

Fig.=10

 

4. Close the Rules and Alerts dialog box.

And now all/desired attachments are downloaded from your email account and saved into the specified destination folder.

Keep reading, share your thoughts, experiences. Feel free to contact us to discuss more. If you have any suggestion / feedback / doubt, you are most welcome.

Stay tuned on Knowledge-Junction, will come up with more such articles.

Thanks for reading 🙂

 

Advertisements

Comments

5 comments on “Automatically download Outlook attachments”
  1. albandrod says:

    Your solution is great, but for Outlook 2016 (for example), will be much easier to configure a Flow to download all your attachments to OneDrive. I have done that and for me it’s perfect 🙂 Just thought I would throw this out there

    1. Thanks albandrod for sharing one more option. But I guess then user will need Office 365 license for using flow (Office 365 feature). And case might be that users might have Outlook but not Office 365.

  2. Robin (Ajay) Robert says:

    Thank you Albandrod for your candour in exceptional technical suggestion. I will try your suggestion shortly and add to this blog. 🙂

  3. katharine says:

    I really appreciate the write up. Really helpful. Found another useful tool on internet, SysTools Outlook Attachment Extractor to download attachments from outlook automatically.

    1. Robin (Ajay) Robert says:

      Thanks a lot! 🙂

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.