Skip to main content

How to automatically download/save attachments from Outlook to a certain folder?

While saving all attachments from a single email in Outlook is straightforward using the Attachments > Save All Attachments option, managing attachments from multiple emails, especially in large quantities, can be more challenging. This article introduces two effective solutions for automatically downloading attachments from Outlook emails to a specific folder. These methods are particularly useful when dealing with numerous emails and attachments, simplifying the process and saving time.


Automatically download Outlook attachments to a folder with VBA and rule

This approach involves using a VBA script, which, when executed with a specific rule, will automatically download and save attachments from Outlook emails to a designated folder. Please proceed with the following steps:

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

    VBA: Auto Save Outlook Attachments into a certain folder

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

    Note: Please locate the line sSaveFolder = "C:\Users\DT168\Documents\outlook-attachments\", and replace it with the path of your desired destination folder.

  3. Save the VBA script and close the Microsoft Visual Basic for Applications window.
  4. Go to the Mail view, and click Home > Rules > Manage Rules & Alerts.
  5. In the opening Rules and Alerts dialog box, please click the New Rule button on the E-mail Rules tab.
  6. In the Rules Wizard dialog box that appears, please select the Apply rule on messages I receive option, and click the Next button.
  7. In the Rules Wizard (Which condition(s) do you want to check?) dialog box, click the Next button without selecting any options. And then click the Yes button in the pop-up Microsoft Outlook dialog box.
  8. In the following Rules Wizard (What do you want to do with the message?) dialog box, proceed as follows:
    1. Check the run a script option. Tip: If you do not see the option, please go to this tutorial on enabling the "run a script" option in Outlook.
    2. Click the blue underlined "a script" text to open the Select Script dialog box. Here, choose the script you added in Step 2 and click the OK button.
    3. Click the Next button to proceed.
  9. In the Rules Wizard (Are there any exceptions?) dialog box, please click the Next button directly.
  10. In the last Rules Wizard dialog box, please name the rule in the Step 1 box, check options as you need in the Step 2 section, and click the Finish button.
  11. Close the Rules and Alerts dialog box.

Result

Now, if you selected the "Run this rule now on messages already in the inbox" option, all attachments from your email account will be downloaded and stored in the specified destination folder. Additionally, if you checked the "Turn on this rule" option, all attachments from incoming emails will be automatically downloaded and saved into the designated folder.


Automatically download Outlook attachments to a folder with Kutools for Outlook

With Kutools for Outlook installed on your computer, its Auto Detach function empowers you to automatically download all or specific Outlook attachments based on your set conditions, conveniently directing them to a chosen folder. Additionally, this feature offers the flexibility to create subfolders. It provides two alternatives for naming these subfolders: you can select from one of the formats, such as [message folder]-[message subject], or opt to append a custom text string as a suffix to your chosen format. This capability greatly improves the organization and accessibility of your attachments.

Kutools for Outlook: Supercharge Outlook with over 100 must-have tools. Test drive it for FREE for 60 days, no strings attached!   Read More...   Download Now!

  1. Click Kutools > Auto Detach to open the feature dialog.
  2. In the Auto Detach Attachments dialog, select the Auto detach all received attachments option, and configure as follows:
    1. Click the browse button to specify the destination folder to save automatically detached attachments.
    2. (Optional) Check the Detach attachments in below style option if you wish to create subfolders for storing the attachments.
      • Create subfolders in below style: Name the subfolders in one of the predefined formats, like [message folder]-[message subject].
      • Rename the saved attachments in below style: Name the subfolders using one of the predefined formats and add a custom text string as a suffix.
    3. (Optional) Check the Attachment icon is still remained in the emails option to keep a visual indicator in the emails that had attachments.
    4. Click Ok.

Result

Starting now, all attachments will be automatically saved to the specified folder upon the receipt of emails.

Tip: If you want to set up automatic detachment of attachments based on specific rules, enable the Auto detach attachments by rules option in the Auto Detach Attachments dialog. After that, click the New button to define your filter conditions and desired save settings.

Notes:

  • Want to access the Auto Detach feature? Download Kutools for Outlook now! Beyond this, Kutools boasts a myriad of 100+ other features and offers a 60-day free trial. Don't wait, give it a try today!
  • If you wish to detach or download existing attachments from multiple/all received emails in Outlook, apply Kutools for Outlook’s Detach All (Attachments) or Save All (Attachments) feature.

Related articles:


Best Office Productivity Tools

Kutools for Outlook - Over 100 Powerful Features to Supercharge Your Outlook

🤖 AI Mail Assistant: Instant pro emails with AI magic--one-click to genius replies, perfect tone, multilingual mastery. Transform emailing effortlessly! ...

📧 Email Automation: Out of Office (Available for POP and IMAP)  /  Schedule Send Emails  /  Auto CC/BCC by Rules When Sending Email  /  Auto Forward (Advanced Rules)   /  Auto Add Greeting   /  Automatically Split Multi-Recipient Emails into Individual Messages ...

📨 Email Management: Easily Recall Emails  /  Block Scam Emails by Subjects and Others  /  Delete Duplicate Emails  /  Advanced Search  /  Consolidate Folders ...

📁 Attachments ProBatch Save  /  Batch Detach  /  Batch Compress  /  Auto Save   /  Auto Detach  /  Auto Compress ...

🌟 Interface Magic: 😊More Pretty and Cool Emojis   /  Boost Your Outlook Productivity with Tabbed Views  /  Minimize Outlook Instead of Closing ...

👍 One-click Wonders: Reply All with Incoming Attachments  /   Anti-Phishing Emails  /  🕘Show Sender's Time Zone ...

👩🏼‍🤝‍👩🏻 Contacts & Calendar: Batch Add Contacts From Selected Emails  /  Split a Contact Group to Individual Groups  /  Remove Birthday Reminders ...

Over 100 Features Await Your Exploration! Click Here to Discover More.

Read More       Free Download      Purchase
 

 

Comments (115)
Rated 4.5 out of 5 · 1 ratings
This comment was minimized by the moderator on the site
Thank you for this information
This comment was minimized by the moderator on the site
May i ask some question?

I usually received mail to many people and many kinds of files.
So i should distinguish each file.
But now, It can`t.

So Did you have any idea for this?
(like chacnged file name or and so on...)

Thank you for your help

BR
Hansu
This comment was minimized by the moderator on the site
Thank you for your great code
This comment was minimized by the moderator on the site
Hi,
I create Module in Microsoft VBA & save it
However when go to create Rules in Outlook, I can't see the select box of "Run a script"
What is the reason & how to fix it?
Thank you
This comment was minimized by the moderator on the site
Hi there,

In some versions of Outlook, especially in more recent updates, the "Run a Script" option might be disabled by default due to security concerns. To enable the "Run a Script" option in Outlook, you usually need to modify the registry settings. Here's a general guide on how to do it:

1. Close Outlook: Make sure Outlook is not running.
2. Open Registry Editor: Press Win + R, type regedit, and hit Enter.
3. Navigate to the Outlook Security Settings: Depending on your version of Outlook, you'll need to navigate to a specific path in the Registry Editor. For example, for Outlook 2016, 2019, and Microsoft 365, you might navigate to HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Security.
4. Modify/Add the Registry Value:
4.1 Right-click in the right pane and choose New > DWORD (32-bit) Value.
4.2 Name the new value as EnableUnsafeClientMailRules.
4.3 Set its value to 1.
5. Close Registry Editor and restart your computer.
6. Open Outlook and check if the "Run a Script" option is available.
This comment was minimized by the moderator on the site
Ale kupa, oszuści. Maile zaczynają znikać. Nie mam moich wiadomości.
This comment was minimized by the moderator on the site
Hi, code works great however I am saving excel files and was wondering how I can modify the saved name. I recieve files like this "exa 2022-08.xlsx" how can I save the excel file as just "2022-08"?

this is my current code and my file saves however as just a file type not excel.

Public Sub PortlandDaily(MItem As Outlook.MailItem)
Dim oAttachment As Outlook.Attachment
Dim sSaveFolder As String
sSaveFolder = "T:\_Portland\Engineering Data\Daily Production Data\Test\"
For Each oAttachment In MItem.Attachments

Dim SplitName() As String
SplitName = Split(oAttachment.DisplayName, ".")

Dim RightName As String
RightName = Right(SplitName(0), 7)

Dim SaveName As String

SaveName = sSaveFolder & RightName

oAttachment.SaveAsFile sSaveFolder & oAttachment.DisplayName

Next
End Sub
Rated 4.5 out of 5
This comment was minimized by the moderator on the site
Hi there,

Please try the code below:
Public Sub PortlandDaily(MItem As Outlook.MailItem)
Dim oAttachment As Outlook.Attachment
Dim sSaveFolder As String
sSaveFolder = "T:\_Portland\Engineering Data\Daily Production Data\Test\"
For Each oAttachment In MItem.Attachments
  Dim SplitName() As String
  SplitName = Split(oAttachment.DisplayName, ".")
  Dim RightName As String
  RightName = Right(SplitName(0), 7) 'You can also declare the file name here, e.g., RightName = "2022-08"
  Dim SaveName As String
  SaveName = sSaveFolder & RightName & "." & SplitName(1)
  oAttachment.SaveAsFile SaveName
Next
End Sub


Amanda
This comment was minimized by the moderator on the site
Hi. is it possible to give the attachment file an entirely new name, using information form the mail (for example the date of delivery).
This comment was minimized by the moderator on the site
Hi,
How can I create a VBA to save attachment (Excel file) in my location drive when email received in my outlook folder and using the file name based on cell value...Many thanks

Regards,
Anthony On
This comment was minimized by the moderator on the site
Bonjour, j'ai réussi à rajouter "exécuter un script" dans les règles et faire fonctionner le script dans outlook. Les pièces jointes d'un mail bien précis s'enregistrent parfaitement dans le dossier demandé. Sauf que j'aimerais enregistrer uniquement les fichiers .txt, et non les .pdf qui s'incrémentent également. Aussi j'ai une autre requête s'il vous plaît, le script fonctionne très bien pour définir un dossier de destination, mais je souhaite définir d'autres règles qui me permettraient d'enregistrer les pièces jointes d'autres mails vers un autre dossier de destination. J'ai essayé de faire un 2e module VBA, cela ne fonctionne pas. J'ai généré un deuxième projet VBA mais Outlook n'en gère qu'un seul. Dans ce cas, comment remédier s'il vous plait ? Merci pour ce tuto très clair pour moi qui suis débutante.
This comment was minimized by the moderator on the site
Hi pearl,
Could you please send the code you generated so that we can fix it?
Amanda
This comment was minimized by the moderator on the site
Hi Can we  download the attachment contains specific letters using VBA code
This comment was minimized by the moderator on the site
Hi DAS,
When you said “the attachment contains specific letters”, did you mean you want to download the attachments from specific letters?
Amanda
This comment was minimized by the moderator on the site
Hi,
I executed the VBA + Rule option and it seemed to work perfectly. However, it recently stopped working with no errors. The rule is set to read the subject line, move to a certain folder if there is a certain subject, and then run the script. I know the trigger is working in the rule because the first action (move to folder) is working as it should.
Any idea why the rule trigger would work, but the documents are no longer being saved?
Things I have tried/checked:-The file path is correct-I added delays in various spots in the vba using application.wait-outlook has been shutdown and re-opened, and so has my laptop
(disclosure: I am a bit of a VBA newbie, but have beginner level coding knowledge)
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations