Skip to main content
 

How to get list of attachments' information in selected mail in Outlook?

Author: Siluvia Last Modified: 2024-08-02

For the received emails which attached with attachments, sometimes you may need to know the detailed information of the attachments, such as the display name, file name and so on. Actually, VBA code can help you easily get the list of attachments’ information in current selected email in Outlook. Please browse the below tutorial for more details.

Get list of attachments’ information in selected mail in Outlook

Office Tab - Enable Tabbed Editing and Browsing in Microsoft Office, Making Work a Breeze
Unlock Kutools for Outlook's free version now and enjoy over 70 features with unlimited access forever
Boost your Outlook 2024 - 2010 or Outlook 365 with these advanced features. Enjoy 70+ powerful features and elevate your email experience!

Get list of attachments’ information in selected mail in Outlook

1. Select the email with attachments which you want to get the information of them.

2. Press the Alt + F11 keys on the keyboard to open the Microsoft Visual Basic for Applications window.

3. Then double click the Project1 > Microsoft Outlook Object > ThisOutlookSession to open the Project1 – ThisOutlookSession window. See screenshot:

the Project1 – ThisOutlookSession window

4. Then copy and paste the below VBA code into the Project1 – ThisOutlookSession window.

VBA code: get list of attachments’ information

Option Explicit
Public Sub GetAttachmentList()
    Dim selItem As Object
    Dim aMail As MailItem
    Dim aAttach As attachment
    Dim Report As String
    
    For Each selItem In Application.ActiveExplorer.Selection
        If selItem.Class = olMail Then
            Set aMail = selItem
            For Each aAttach In aMail.Attachments
                Report = Report & vbCrLf & "------------------------------------------------------------------------" & vbCrLf
                Report = Report & GetAttachmentInfo(aAttach)
            Next
            Call CreateReportEmail("Attachment Report", Report)
        End If
    Next
End Sub
 
Public Function GetAttachmentInfo(attachment As attachment)
    Dim Report
    GetAttachmentInfo = ""
    Report = Report & "Index: " & attachment.Index & vbCrLf
    Report = Report & "Display Name: " & attachment.DisplayName & vbCrLf
    Report = Report & "File Name: " & attachment.FileName & vbCrLf
    Report = Report & "Block Level: " & attachment.BlockLevel & vbCrLf
    Report = Report & "Path Name: " & attachment.PathName & vbCrLf
    Report = Report & "Position: " & attachment.Position & vbCrLf
    Report = Report & "Size: " & attachment.Size & vbCrLf
    Report = Report & "Type: " & attachment.Type & vbCrLf
    
    GetAttachmentInfo = Report
End Function
Sub CreateReportEmail(Title As String, Report As String)
    Dim aMail As MailItem
    
    Set aMail = Application.CreateItem(olMailItem)
        
    aMail.Subject = Title
    aMail.Body = Report
    
    aMail.Display
End Sub 

5. Press F5 key on the keyboard to run the VBA code.

6. Now a Macros dialog box pops up, please click the Run button.

a Macros dialog box

7. After clicking the Run button in the Macros dialog box, a new message window will be created with all attachments information of selected email listed inside the email body. See screenshot:

a new message window is created with all attachments information of selected email listed inside the email body

Note: This VBA code can be applied to Outlook 2007, 2010 and 2013


Best Office Productivity Tools

Breaking News: Kutools for Outlook Launches Free Version!

Experience the all-new Kutools for Outlook FREE version with 70+ incredible features, yours to use FOREVER! Click to download now!

🤖 Kutools AI : Uses advanced AI technology to handle emails effortlessly, including replying, summarizing, optimizing, extending, translating, and composing emails.

📧 Email Automation: Auto Reply (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: 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   /  Remind you when important emails come  /  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 ...

Instantly unlock Kutools for Outlook with a single click—permanently free. Don't wait, download now and boost your efficiency!

kutools for outlook features1 kutools for outlook features2