How to save attachments without opening the email in Outlook?
You may frequently need to save attachments from the received emails to your computer discs. It is easy to save an attachment or all attachments from an email message, but how to save attachments from multiple emails at once? Normally, you need to repeatedly open the emails and save the attachments. Is there any tricks to get rid of the repeatedly operations? Here the methods in this tutorial can help you.
Save attachments from one or more emails without opening with VBA code
Save attachments from one or more emails without opening with an amazing tool
Save attachments from one or more emails without opening with VBA code
The below VBA code can help to save attachments from one or more emails at the same time without opening the emails in Outlook. Please do as follows.
1. Select an email or multiple emails which you will save the attachments, press the Alt + F11 keys to open the Microsoft Visual Basic for Applications window.
2. Expand the Microsoft Outlook Objects folder, double click the ThisOutlookSession to open the Code window, and then copy the below VBA code into the it.
VBA code: Save attachments without opening the emails
Public Sub SaveAttachmentsWithoutOpening()
'Updated by Extendoffice 20191008
Dim xMailItem As Outlook.MailItem
Dim xAttachments As Outlook.Attachments
Dim xAttachment As Outlook.Attachment
Dim i As Long
Dim xCount As Long
Dim xFileName As String
Dim xSavePath As String
Dim xOriginalFiles As String
On Error Resume Next
Set xShell = CreateObject("Shell.Application")
Set xFolder = xShell.BrowseForFolder(0, "Select a folder:", 0, strStartingFolder)
If Not TypeName(xFolder) = "Nothing" Then
Set xFolderItem = xFolder.self
xSavePath = xFolderItem.Path & "\"
Else
xFileName = ""
Exit Sub
End If
For Each xMailItem In Outlook.ActiveExplorer.Selection
Set xAttachments = xMailItem.Attachments
xCount = xAttachments.Count
xOriginalFiles = ""
If xCount > 0 Then
For i = xCount To 1 Step -1
Set xAttachment = xAttachments.Item(i)
If IsEmbeddedAttachment(xAttachment) = False Then
xFileName = xSavePath & xAttachment.FileName
xAttachment.SaveAsFile xFileName
xAttachment.Delete
If xMailItem.BodyFormat <> olFormatHTML Then
xOriginalFiles = xOriginalFiles & vbCrLf & "file://" & xFileName
Else
xOriginalFiles = xOriginalFiles & "<br>" & "<a href='file://" & xFileName & "'>" & xFileName & "</a>"
End If
End If
Next i
If xMailItem.BodyFormat <> olFormatHTML Then
xMailItem.Body = "The file(s) were saved to " & xOriginalFiles & vbCrLf & vbCrLf & xMailItem.Body
Else
xMailItem.HTMLBody = "<p>" & "The file(s) were saved to " & xOriginalFiles & "</p>" & xMailItem.HTMLBody
End If
xMailItem.Save
End If
Next
Set xAttachments = Nothing
Set xMailItem = Nothing
End Sub
Function IsEmbeddedAttachment(Attach As Attachment)
Dim xItem As MailItem
Dim xCid As String
Dim xID As String
Dim xHtml As String
On Error Resume Next
IsEmbeddedAttachment = False
Set xItem = Attach.Parent
If xItem.BodyFormat <> olFormatHTML Then Exit Function
xCid = ""
xCid = Attach.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001F")
If xCid <> "" Then
xHtml = xItem.HTMLBody
xID = "cid:" & xCid
If InStr(xHtml, xID) > 0 Then
IsEmbeddedAttachment = True
End If
End If
End Function
4. Press the F5 key to run the code. Then a BrowseForFolder window pops up, please select a folder to save the attachments, and then click the OK button.
Then all attachments in selected emails are saved into the selected folder immediately.
Note: All attachments will be detached from the emails and keep the corresponding saving path links in the email body.
Save attachments from one or more emails without opening with an amazing tool
If you are a newbie in VBA, the method in this section will be your good choice.
Here recommend the Save All attachments utilities of Kutools for Outlook for you. If you just want to save the attachments without detaching from selected emails, the Save All attachments feature can help you easily get it done. Please do as follows.
Before applying Kutools for Outlook, please download and install it firstly.
1. Select the emails containing the attachments you will save, click Kutools > Attachment Tools > Save All.
2. In the Save Settings dialog box, you need to:
- 2.1) In the Save attachment(s) to this folder section, choose a folder to save the attachments;
- 2.2) The Save attachment(s) in below style box is optional for you to create a subfolder with certian style to save the attachments, or rename the saved attachments with certian style.
- 2.3) Click OK to start saving all attachmentsn from selected emails.
Tips: With the above configurations, all attachments will be saved into the specified folder. If you only want to save some certian attachments such as only save the PDF files with certian word "invoice" in the file name, you can configure the filter conditions as follows.
- Click the Advanced options button to expand the Filter conditions;
- Specify the conditions based on your needs.
Tips: Here I check the Attachment name contains box and then enter "invoice" into the text box, then check the Attachment type box, enter ".pdf" into the textbox.
3. In the next popping up dialog box, click Yes to continue.
Then attachments in selected emails are saved into the specified folder at once.
Tips: For detaching attachments from selected emails and leaving only the attachment hyperlinks in the email body, the Detach All attachments feature can help.
If you want to have a free trial (60-day) of this utility, please click to download it, and then go to apply the operation according above steps.
Related articles
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 ideal? This article will introduce two solutions to automatically download attachments from Outlook to a certain folder.
Keep attachments when replying in Outlook
When we forward an email message in Microsoft Outlook, original attachments in this email message are remained in the forwarded message. However, when we reply an email message, the original attachments will not be attached in the new reply message. Here we are going to introduce a couple of tricks about keeping original attachments when replying in Microsoft Outlook.
Search words within attachment (content) in Outlook
When we typing a keyword in the Instant Search box in Outlook, it will search the keyword in emailsβ subjects, bodies, attachments, etc. But now I just need to search the keyword in attachment content only in Outlook, any idea? This article shows you the detailed steps to search words within attachment content in Outlook easily.
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 Pro: Batch 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.
![](http://cdn.extendoffice.com/images/stories/ad-sun/kto-bottom-ad/kutools-100.png)
![](http://cdn.extendoffice.com/images/stories/ad-sun/kto-bottom-ad/kutools-plus-100.png)