Skip to main content

How To Save Only Specific (Excel) Attachment In Outlook?

Outlook provides the Save All Attachments feature to help you saving all attachments in an email to a specific folder at one time. However, if you want to save only certain types of attachments in one or more emails, such as Excel workbooks, Word documents and so on, how do you achieve it? In this tutorial, we provide you two methods to solve this problem.

Save only specific file format attachments in Outlook with VBA code
Easily save only specific file format attachments in Outlook with an amazing tool


Save only specific file format attachments in Outlook with VBA code

The following VBA code can help to save only specific file format attachments in one or more selected emails to a specific folder. Please do as follows.

1. Launch your Outlook. In the Mail list, select one or more emails from which you want to save only attachments in a specific file format.

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 20210617
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 & "
" & "" & xFilePath & "" End If End If Next 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.

Note: For multiple file extensions, you need to separate them with commas.

Then only the specified attachments are saved.


Easily save only specific file format attachments in Outlook with an amazing tool

If you are new to VBA, here we recommend you to use the Save All attachments feature of Kutools for Outlook. With this feature, you can easily save only attachments in a specific file format in Outlook.

1. Select the emails from which you want to save only attachments in a specific file format.

2. Click Kutools > Attachment Tools > Save All.

3. In the Save Settings dialog box, you need to configure as follows.

3.1) In the Save attachment(s) to this folder section, click the button to select a folder to save the attachments;
3.2) Click the Advanced options button to unfold the dialog box;
3.3) In the Filter conditions section, check the Attachment type checkbox, then enter the file extension of the attachments you will save into the text.
Tips: For multiple file extensions, you need to separate them with semicolons.
3.4) Click the OK button. See screenshot:

4. A dialog box pops up reminding you if you want to save the attachments, click OK to continue.

5. Then another dialog box pops up to tell you how many attachments have been saved, click the OK button.

Now only the specific file format attachments are saved.

Click here to know more about this feature.

  If you want to have a free trial (30-day) of this utility, please click to download it, and then go to apply the operation according above steps.


Related articles:


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 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 (0)
No ratings yet. Be the first to rate!
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
Rate this post:
0   Characters
Suggested Locations