How to Quickly Get the List of Attachment Information from an Email with Outlook VBA

Have you ever wanted to extract the list of attachment information from an open or selected email? You must feel it time-consuming to get it manually. This article will introduce you a quick method to achieve it with Outlook VBA.

For some reasons, you may be required to get the list of attachment information from an email, including the attachment name, index and size, etc. Perhaps it’ because that you need to make a report or reply the email with the list of attachments. Regardless of why you require it, if you do it manually, namely checking and copying one by one, it will be quite troublesome and error prone. So why don’t you resort to VBA? It can help you to get all kinds of information about the attachments with utmost ease. Here are the detailed steps and corresponding VBA codes.

Extract the List of Attachment Information from an Email

  1. At first, launch Outlook as normal.
  2. Then press the “Alt + F11” shortcuts to access the VBA editor.
  3. In the subsequent window, then you ought to open a module which is not in use or insert a new module by selecting “Insert” > “Module”.
  4. Next you can copy and paste the following VBA codes into the new module.
Sub GetlAttachmentList()
    Dim olItem As MailItem
    Dim olAtt As attachment
    Dim olAtts As Attachments
    Dim sAttInfo As String
    Dim Dataobj As DataObject
 
    Select Case Application.ActiveWindow.Class
           Case olExplorer
                Set olItem = ActiveExplorer.Selection.Item(1)
           Case olInspetor
                Set olItem = ActiveInspector.CurrentItem
    End Select
 
    If TypeOf olItem Is MailItem Then
       Set olAtts = olItem.Attachments
       If olAtts.Count > 0 Then
          For Each olAtt In olAtts
              sAttInfo = sAttInfo & vbCrLf & "------------------------------------------------------------" & vbCrLf
              sAttInfo = sAttInfo & "No. " & olAtt.Index & " : " & olAtt.DisplayName & " Size: " & olAtt.Size & ".KB"
          Next
          sAttInfo = sAttInfo & vbCrLf & "------------------------------------------------------------"
          'Copy the attachment list
          Set Dataobj = New MSForms.DataObject
          Dataobj.SetText sAttInfo
          Dataobj.PutInClipboard
       End If
    End If
End Sub

VBA Codes - Extract the List of Attachment Information from an Email

  1. After that, you can close the current window and go to add the new project to Quick Access Toolbar.
  • Firstly, go to “File” > “Options”.
  • Subsequently, in “Outlook Options” window, switch to “Quick Access Toolbar” tab.
  • Then follow the steps shown in the screenshot below to add new macro.Add the GetAttachmentList Macro to Quick Access Toolbar
  1. After backing to main Outlook window, you can have a try.
  • Firstly, select an email and hit the macro button in Quick Access Toolbar.
  • Then the list of attachments in this email will be put in clipboard.
  • Now you can open a new email or any blank document and press “Ctrl + V”. Then you will see the list, like the following screenshot:Get the List of Attachment Information

Never Delay When Meeting Outlook Problems

There is no denying that Outlook has a biggest downside – frequent errors, such as Outlook email error, Outlook crash, freezing or not responding and so on. Thus multiple users must have been plagued a lot. Actually you can first use the inbox repair tool to have a try. If it fails, then you may need to turn to a more powerful tool, like DataNumen Outlook Repair.

Author Introduction:

Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including repair corrupted SQL Server mdf db and outlook repair software products. For more information visit www.datanumen.com

One response to “How to Quickly Get the List of Attachment Information from an Email with Outlook VBA”

  1. After yoou do have a farm or two with seeds planted, you should create some
    chests to keep your items with your house.
    The sssssssss lets you know you’ve got approx 2 seconds before
    that damn creeper blows up, destroying your hard work, and frequently
    killing you too. At the time of this writing, the 360 version is a feww updates behind the current PC version, butt according to news found for thee internet and good sources, eventually both the versions will probably be trapped to every other.

Leave a Reply

Your email address will not be published. Required fields are marked *