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 only specific (excel) attachment in Outlook?

Outlook provides a Save All Attachments feature for you to quickly save all attachments in an email to a specific folder at once. However, if you want to save only specific type of attachment in an email, such as Excel attachment, Word document and so on, what can you do to achieve it? Here we provide a VBA method to solve the problem.

Save only specific attachment in Outlook


Easily save all attachments from multiple selected emails to folder:

With the Detach All attachments utility of Kutools for Excel, you can easily save all attachments from multiple selected emails to specified folder in Outlook as below screenshot showed.

Kutools for Outlook: with more than 40 handy Outlook add-ins, free to try with no limitation in 45 days. Download and free trial Now!

Kutools for Outlook: 100+ New Advanced Tools for Outlook.
Office Tab: Enable Tabbed Editing and Browsing in Office, Just Like Chrome, Firefox, IE 8/9/10.
Classic Menu: Bring Old Menus and Toolbars Back to Office 2007, 2010, 2013, 2016 and 2019.

Save only specific attachment in Outlook

The below VBA code can help to save only specific attachment in an email or multiple emails to a specific folder. Please do as follows.

1. Launch your Outlook, in the mailing list, select an email or multiple emails you will save specific attachment from.

2. Press the Alt + F11 keys to open the Microsoft Visual Basic for Applications window. In the opening window, click Insert > Module, and then copy below VBA code into the Module window.

VBA code: Save only specific attachment in an email or multiple emails to a folder

Public Sub SaveSpecifyAttachments()
'Updated by ExtendOffice 20181130
Dim xItem As Object, xFldObj As Object
Dim xSelection As Selection
Dim xAttachment As Outlook.Attachment
Dim xSaveFolder As String
Dim xFSO As Scripting.FileSystemObject
Dim xFilePath, xFilesSavePath As String
Dim xExtStr As String, xExt As String
Dim xExtArr() As String, xS As Variant
On Error Resume Next
Set xFldObj = CreateObject("Shell.Application").BrowseforFolder(0, "Select a Folder", 0, 16)
Set xFSO = New Scripting.FileSystemObject
If xFldObj Is Nothing Then Exit Sub
xSaveFolder = xFldObj.Items.Item.Path & "\"
Set xSelection = Outlook.Application.ActiveExplorer.Selection
xExtStr = InputBox("Attachment Format:" + VBA.vbCrLf + "(Please separate multiple file extensions by comma.. Such as: .docx,.xlsx)", "Kutools for Outlook", xExtStr)
If Len(Trim(xExtStr)) = 0 Then Exit Sub
For Each xItem In xSelection
    If xItem.Class = olMail Then
        xFilesSavePath = ""
        For Each xAttachment In xItem.Attachments
            xFilePath = xSaveFolder & xAttachment.FileName
            xExt = "." & xFSO.GetExtensionName(xFilePath)
            xExtArr = VBA.Split(xExtStr, ",")
            xS = VBA.Filter(xExtArr, xExt)
            If UBound(xS) > -1 Then
                xAttachment.SaveAsFile xFilePath
                If xItem.BodyFormat <> olFormatHTML Then
                    xFilesSavePath = xFilesSavePath & vbCrLf & "<file://" & xFilePath & ">"
                Else
                    xFilesSavePath = xFilesSavePath & "<br>" & "<a href='file://" & xFilePath & "'>" & xFilePath & "</a>"
                End If
            End If
        Next
        If xItem.BodyFormat <> olFormatHTML Then
            xItem.Body = vbCrLf & "The file(s) were saved to " & xFilesSavePath & vbCrLf & xItem.Body
        Else
            xItem.HTMLBody = "<p>" & "The file(s) were saved to " & xFilesSavePath & "</p>" & xItem.HTMLBody
        End If
        xItem.Save
    End If
Next
Set xFSO = Nothing
End Sub

3. Click Tools > References, in the References – Project dialog, check the Microsoft Scripting Runtime box and click the OK button.

4. Press the F5 key to run the code. In the popped out Browse for Folder dialog box, choose one folder to save the attachments.

5. And then, click OK, in the following Kutools for Outlook dialog box, enter the file extension of the attachment you will save into the text box and click OK.

Then only the specified attachments are saved.

Notes:

1. If you want to save different type of attachments, please enter the file extensions into the text box and separate them by comma.

2. After saving, an attachment saving path is displayed on the message body. You can open the attachment by clicking the hyperlink directly.


Related articles:



Kutools for Outlook

More than 100 Advanced Functions for Outlook 2010, 2013, 2016, 2019 and 365

screen shot kutools for outlook tiny for banner 201812

More Features  |  Free Download  |  Only $39.00 for hundreds of functions

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.