Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

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 Detach All attachments and the Save All attachments utilities of Kutools for Outlook for you. For detaching attachments from the selected emails, please apply the Detach All attachments feature, if you just want to save the attachments without detaching from the emails, apply the Save All attachments feature. Please do as follows.
Before applying Kutools for Outlook, please download and install it firstly.

1. Select the emails containing the attachments you will detach or save, click Kutools > Detach All or Save All based on your needs.

2. In the next opening dialog box, you need to:

  • Choose a folder to save the attachments;
  • Select a subfolder style as you need (Optional);
  • Specify the attachments with certain extensions you will detach or save only (Optional);
    Tips: If you only want to detach or save word document attachments, please check the Only detach or save attachments with following extensions boxes, enter .docx into the text box. For multiple extensions, please use “;” to separate them, such as .docx;.txt.
  • Click the OK button. See screenshot:

3. In the next popping up dialog box, click Yes to continue.

Then all attachments in selected emails are detached or saved into the specified folder at once.

  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.


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
 
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.

Be the first to comment.