Note: The other languages of the website are Google-translated. Back to English

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: Add more than 100 handy tools for Outlook, free to try with no limitation in 60 days. Read More      Free Trial 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:


Kutools for Outlook - Brings 100 Advanced Features to Outlook, and Make Work Much Easier!

  • Auto CC/BCC by rules when sending email; Auto Forward Multiple Emails by custom; Auto Reply without exchange server, and more automatic features...
  • BCC Warning - show message when you try to reply all if your mail address is in the BCC list; Remind When Missing Attachments, and more remind features...
  • Reply (All) With All Attachments in the mail conversation; Reply Many Emails in seconds; Auto Add Greeting when reply; Add Date into subject...
  • Attachment Tools: Manage All Attachments in All Mails, Auto Detach, Compress All, Rename All, Save All... Quick Report, Count Selected Mails...
  • Powerful Junk Emails by custom; Remove Duplicate Mails and Contacts... Enable you to do smarter, faster and better in Outlook.
shot kutools outlook kutools tab 1180x121
shot kutools outlook kutools plus tab 1180x121
 
Comments (104)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hello Everyone The Script is not working for me.I there something else that needs to be done. Public Sub SaveAttachmentsToDisk(MItem As Outlook.MailItem) Dim oAttachment As Outlook.Attachment Dim sSaveFolder As String sSaveFolder = "\\MHO-ITD-SM\Users\smutharaju\Desktop\Ranjith\Outlook Attachments" For Each oAttachment In MItem.Attachments oAttachment.SaveAsFile sSaveFolder & oAttachment.DisplayName Next End Sub
Srinivas
This comment was minimized by the moderator on the site
Hi SRINIVAS, I believe you need to add the Drive letter to the beginning of your link. i.e. C:\users\test\etc Hopes this helps! Andrew
Andrew
This comment was minimized by the moderator on the site
In VBA you also need to add a final backslash at the end of your file path. As follows. "D:\OutlookAttachments\" Hope this fixes any issues. Matt
Matt
This comment was minimized by the moderator on the site
HI

the VBA script worked great for me..... once - never again.

I even deleted the files in the folder and re ran and nothing.

What am I doing wrong ? - the rule is running as I get it to display an alert at the same time
Dave Brammer
This comment was minimized by the moderator on the site
[quote]Hello Everyone The Script is not working for me.I there something else that needs to be done. Public Sub SaveAttachmentsToDisk(MItem As Outlook.MailItem) Dim oAttachment As Outlook.Attachment Dim sSaveFolder As String sSaveFolder = "\\MHO-ITD-SM\Users\smutharaju\Desktop\Ranjith\Outlook Attachments" For Each oAttachment In MItem.Attachments oAttachment.SaveAsFile sSaveFolder & oAttachment.DisplayName Next End SubBy Srinivas[/quote] Same here I tried all option I feel script is running but I still don't see files loading in my computer specified path.can some one help me most appreciated
Kalyan
This comment was minimized by the moderator on the site
script seems to not be working either, everything is programmed fine, the code etc. and no attachments are pulling through when i run the rule?? running on office 2007? any ideas why??
Danny
This comment was minimized by the moderator on the site
Hello, I have tried the option 1 (Automatically download Outlook attachments to folder with VBA and rule) and it works perfectly. I have following two queries: i) Is there a way outllook download same attachment at multiple share path with reaming the file? ii) It also saves attachment with cursor on A1 in eachsheet and sheet1 should be selected. So when you open the file from the path sheet should be open with cursor on A1. Thank you so much in advance!! Regards, Bhavesh Luhana
Bhavesh Luhana
This comment was minimized by the moderator on the site
Can this rule or similar be applied to a webmail version of Outlook?
Eugene
This comment was minimized by the moderator on the site
Hi, I have been trying to follow the steps as directed. but i do not get the 'run a script' option after saving the macro. I have enabled the macros, restarted outlook several times. but it still the option still does not work. Please help. Thanks!
Avnika Rastogi
This comment was minimized by the moderator on the site
I agree with AVNIKA. I have the same problem :-|
Dinushe
This comment was minimized by the moderator on the site
Hi, I have been trying to follow the steps as directed i selected all the above options but after selecting the "run a script" option and selecting the link "a script" I do not get the script in that dialogue box. Please help as soon as possible. Thanks!
Harsha
This comment was minimized by the moderator on the site
I had this same issue. I found a resolution here: https://answers.microsoft.com/en-us/msoffice/forum/msoffice_outlook-mso_win10/the-option-to-run-a-scritp-has-disappeared-from/d289e698-47fa-497a-80fa-633067a0de37#ThreadAnswers<br /> Once i updated my registry with the key... it started working as it was supposed to again. Give it a try and see if it works for you.
Dean
This comment was minimized by the moderator on the site
Thankyou so much for the so clearly mentioned steps.... These helped me alot and made my job very easy... THANKYOU.....!!
Harsha
This comment was minimized by the moderator on the site
This works really well for me Public Sub SaveAttachmentsToDisk(MItem As Outlook.MailItem) Dim oAttachment As Outlook.Attachment Dim sSaveFolder As String sSaveFolder = "\\Dck-server-02\g\00 Uploads\" For Each oAttachment In MItem.Attachments oAttachment.SaveAsFile sSaveFolder & oAttachment.DisplayName Next End Sub As you can see i have left the filename that is the attachment as the same for when it copies to the network drive. However, if multiple emails come through with the same filename for the attachment, the script then allows the most recent attachment to overwrite the previous attachment in the network folder. Is there an edit which i can input into the script which will append a "-1" "-2" "-3" etc... to the end of the attachment filename? So for example, if the attachment is named "inspection" and i get multiple that come through can i have them renamed to "inspection-1" "inspection-2" "inspection-3" Any help would be appreciated SO MUCH! Thank you.
Janayah
This comment was minimized by the moderator on the site
Hi Jayayah. Try doing a check for the file before saving. Dim filepath As String filepath = Dir(sSaveFolder & oAttachment.DisplayName) If filepath = "" Then oAttachment.SaveAsFile sSaveFolder & oAttachment.DisplayName Else oAttachment.SaveAsFile sSaveFolder & "1-" & oAttachment.DisplayName End if and so on... play about with the code and let me know how you get on..
Bob
This comment was minimized by the moderator on the site
is there any possibility to change this so that only files that have certain words in their name are copied?
fabian
This comment was minimized by the moderator on the site
Can Kutools be set up so that it only saves attachments from certain emails based on the subject? And can the same file be saved to multiple directories from a single email? We want to use this for report distribution instead of email.
Jess
This comment was minimized by the moderator on the site
Hi thanks a lot this work but only once, next times the file isnt saved in the disk :( I dont know why, any idea? thanks
Marcos
This comment was minimized by the moderator on the site
Hi, I have the same problem (It work only once). Could you solve the problem?
Bence
This comment was minimized by the moderator on the site
Hi,
Please check if the destination folder outlook-attachments existing or not. And more information about this problem will be helpful. Thanks!
Tech Support
This comment was minimized by the moderator on the site
Hi, I must say its superb script, it resolved 80% of my work but still I have one issue. The attachments I receive is with new date and time-stamp on daily basis and I want to auto save these attachment but by removing the date/time stamp so that next time it will replace/overwrite and save new copy with same name.,Do not want every day attachments getting save with new date. instead same file needs to be replaced at same location. Can you please help.
vandy
This comment was minimized by the moderator on the site
Hi All, How can I set this up so that I have a different script to send files to different folders? Thank you for any help offered in advance!
Nathan
This comment was minimized by the moderator on the site
Hi I am setting up the script you have at the top of the page and it works OK, however, I would like to name the attachment being saved so that it overwrites the old one. What would I need to add to get this to happen? Thanks David
David
This comment was minimized by the moderator on the site
Hi all experts, I try hard to setup the automatic download as described above by using VBA script but nothing has been saved in the target folder. I tried this on Outlook 2007 and Outlook 2010, and also make sure the folder has all the necessary authorities. But still no single attachment has been saved. Can anyone help me on this? Cheers Stanley
Stanley
This comment was minimized by the moderator on the site
On Outlook 2013 the "run a script" option isnt available can I do anything else to save attachments from an email without using Kutools
Ndesouza
This comment was minimized by the moderator on the site
If the option for "Run a Script" is missing, it's because it's blocked by default now since a security update a few months ago. Look here for more information: https://www.slipstick.com/outlook/rules/outlook-2016-run-a-script-rules/
WarrenDB
This comment was minimized by the moderator on the site
Hi, script works fine ... but want to extract the PDF's from a sub-folder, not from the main Inbox. Is there a way to change the script ?
Thank you in advance !
Eric VT
This comment was minimized by the moderator on the site
Hi Eric,
Below VBA script will save all PDF attachments from mail folders. For saving from a certain folder, you can specify the folder when manually running the rule.


Public Sub SaveAttachmentsToDisk(EmailItem As Outlook.MailItem)
Dim xAttachment As Outlook.Attachment
Dim xDotPos As Integer
Dim xSavePath As String, xFileType As String
xSavePath = "C:\Users\DT168\Documents\outlook-attachments\"
For Each xAttachment In EmailItem.Attachments
xDotPos = InStrRev(xAttachment.DisplayName, ".")
xFileType = Mid(xAttachment.DisplayName, xDotPos, Len(xAttachment.DisplayName) - xDotPos + 1)
If xFileType = ".pdf" Then
xAttachment.SaveAsFile xSavePath &amp; xAttachment.DisplayName
End If
Next
End Sub
Tech Support
This comment was minimized by the moderator on the site
Hello, Is there a VBA script for CSV attachment. I currently have report jobs that automatically goes into named folders in outlook I would now like for those files in the folders extract itself and go into the corresponding folders on my desktop. Hope this makes sense. Please Help! I am very new to VBA.
Raynardo Pardo
This comment was minimized by the moderator on the site
I have done all scripting to download the attachments from outlook mail and my script is working fine when i run it manually. I would like to automate the process using the Rule option. But i couldn't see my macro in the Rules Wizard window. I have enabled the below option in the registry too
HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Security
DWORD: EnableUnsafeClientMailRules
Value: 1

But still i couldn't see my macro in the Rule Wizard list. My rule wizard list is empty but i have created the macro already and its manually working fine. I have to bring the macro in my Rules wizard to automate the process. Please help me if you have any ideas!
Dhinesh
There are no comments posted here yet
Load More
Leave your comments
Posting as Guest
×
Rate this post:
0  Characters
Suggested Locations