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
End Sub

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




  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:







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










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)




I. Outlook 2016

Windows Registry Editor Version 5.00




ii. Outlook 2013

Windows Registry Editor Version 5.00




iii. Outlook 2010

Windows Registry Editor Version 5.00



d. Run the .reg file as an admin




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

Back to Attachment process.

Fig.6 (Repeat)








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 🙂


You may also like...

13 Responses

  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

  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.

  4. hsauce says:

    Any idea why the option to check the box for ‘run a script’ wouldn’t show up? This is the perfect solution for what I need and I don’t where to go from here.

    • Robin (Ajay) Robert says:

      Unable to see run a script option in outlook?

      • Stu says:

        Yes, unfortunately, the Run a Script option is disabled by default now, so this is no longer possible for those who don’t want to go digging in the registry.

        Alternatives welcomed!?

  5. Syed Minhaj Uddin says:

    Thumb Up! You made my day

  6. Akanksha kumari says:

    I tried this. The process is complete. Rule is created and implemented but the attachments are not getting stored.

  7. Hi Robin, Microsoft Visual Basic for Applications window is not supported in my office laptop

    Is there any alternate option for Visual Basic?

  8. Does anyone know whether it is possible to change the name of the file attachment being saved in the process? We have a requirement where an app produces attachments with random file names which we would ideally like to convert to something meaningful as we download them…

    • petergdownload says:

      Easy. Just edit the bit of code at the start to have the name you want:

      oOutlookAttachment.SaveAsFile sSaveAttachmentsFolder &

      can become

      oOutlookAttachment.SaveAsFile sSaveAttachmentsFolder &
      format(date(),”yymmdd”) & ” – Important File” & left(OutlookAttachment.DisplayName,4)

      this would save as

      200916 – Important File.txt

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

%d bloggers like this: