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
- At first, launch Outlook as normal.
- Then press the “Alt + F11” shortcuts to access the VBA editor.
- 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”.
- 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
- 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.
- 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:
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
Leave a Reply