Skip to main content

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

Generally speaking, you can save all attachments of one email with clicking Attachments > Save All Attachments in Outlook. But, if you need to save all attachments from all received emails and receiving emails, any ideas? This article will introduce two solutions to automatically download attachments from Outlook to a certain folder.


Automatically download Outlook attachments to folder with VBA and rule

This method will introduce a VBA script, and run this scrip with a rule to automatically download and save Outlook attachments to a certain folder. 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 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 find out sSaveFolder = "C:\Users\DT168\Documents\outlook-attachments\", and replace the destination folder’s path as you need.

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. See screenshot:

5. In the opening Rules and Alerts dialog box, please click the New Rule button on the E-mail Rules tab. See screenshot:

6. Now in the Rules Wizard dialog box, please click to 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, please uncheck any option, and click the Next button. And then click the Yes button in the popping up Microsoft Outlook dialog box. See screenshot:

8. Now in the Rules Wizard (what do you want to do with the message?) dialog box, please: (1) Check the run a script option; (2) Click the text of a script to open the Select Script dialog box, select the script we added in Step 2 and click the OK button; (3) Click the Next button.

9. In the Rules Wizard (Are there any exceptions?) dialog box, please click the Next button directly.

10. Now 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.

And now all attachments are downloaded from your email account and saved into the specified destination folder. And all attachments of incoming emails will be automatically downloaded and saved into the specified folder too.


Automatically download Outlook attachments to folder with Kutools for Outlook

If you have Kutools for Outlook installed, you can apply its Auto Detach option to automatically download all Outlook attachments and save to a certain folder easily.

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 > Enable to enable the Auto Detach feature.

2. Go ahead to click Kutools > Auto Detach > Auto Detach Manager.

3. In the Auto Detach Attachments dialog, check the Auto detach all received attachments option, and then configure as follows:
(1) Click the browse button  to specify the destination folder to save automatically detached attachments;
(2) It’s optional to check the Create subfolders in the following style option, and then select one subfolder style from below drop-down list;
(3) It’s optional to check the Only detach attachments with following extension option, and then type attachment file extensions into below box;
(4) It’s optional to check the Attachment icon is still remained in the emails options.

Note: If you need to automatically detach attachments by senders, you can check the Auto detach attachments by rules option, click the New button, and then type the sender’s email address and specify destination folder in the second Auto Detach Attachments dialog.

4. Click the Ok button to save the settings.

From now on, all attachments (or attachments with specified file extensions, or attachments from specified senders based on your settings) will be automatically saved.

Note: You can apply Kutools for Outlook’s Detach All (Attachments) feature or Save  All (Attachments) feature to quickly download/save all attachments from multiple/all received emails in Outlook.


Demo: Automatically download Outlook attachments to folder with Kutools for Outlook


Tip: In this Video, Kutools tab is added by Kutools for Outlook. If you need it, please click here to have a 60-day free trial without limitation!


Related articles:


Best Office Productivity Tools

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

📧 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 (109)
Rated 4.5 out of 5 · 1 ratings
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,
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)
This comment was minimized by the moderator on the site
Hi,when i use the Kutools plugin, it is possibile to add a rule for all the sender wich include a text in the sender email?for example i want to download all the ".txt" attachments recived from all the senders containing "@amazon.com" in his email adress?
thank you!!
This comment was minimized by the moderator on the site
Hi
I have a problem. I can't find "run a script" command in second step dialog window while creating the rule :/
I have the Outlook2016, any ideas how to find it or turn it on ?
This comment was minimized by the moderator on the site
This comment was minimized by the moderator on the site
Hi,
The script works very well.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

Everything works great but what if I have a number of attachments in the email and I only want to save the excel and pdf files which are attached and not all the files attached to the email?
Does someone can help?
Much appreciated.Joao
This comment was minimized by the moderator on the site
Please share your mail id i will send my custom desinged form to Download the attachments.
This comment was minimized by the moderator on the site
I got the script to run, everything works, but is there anyway to prevent the original email from being deleted? It is going directly into my "permanently deleted" files. I'd like the emails to stay right where they are rather than being deleted.
This comment was minimized by the moderator on the site
Public Sub SaveAttachmentsToDisk(MItem As Outlook.MailItem)
Dim oAttachment As Outlook.Attachment
Dim sSaveFolder As String
MsgBox "E:\Dropbox\Apps\Attachments" & F
sSaveFolder = "E:\Dropbox\Apps\" & Format(Now(), "dd.mm_hh.mm.ss")
For Each oAttachment In MItem.Attachments
oAttachment.SaveAsFile sSaveFolder & oAttachment.DisplayName
Next
End Sub
This comment was minimized by the moderator on the site
HI All, I did all the steps but my script is not working.
This comment was minimized by the moderator on the site
Hi Shilpa. At colabel we are developing a no-code solution that can automatically categorize and store your attachments into folders. We're currently looking for qualified beta users willing to test our solution for free. In case you think we might help you, just send me an email at
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