How to Batch Print All Attachments in Multiple Emails with Outlook VBA

If you would like to print out all the attachments in multiple selected emails in bulk, you can utilize the method introduced in this article. It is using a piece of VBA code to achieve it in quick time.

As you can see, when you select a single attachment, there is a direct “Quick Print” feature available in the “Attachments” ribbon. However, when you select over one attachment, the “Quick Print” button will be disabled, not to mention to print all attachments in many selected emails. Therefore, provided that you want to batch print all attachments in several mails in one go, you have to seek other ways, such as any third party tools or VBA. Focused on this need, here we will expose a piece of VBA code to you, which can help you get it simply via one click.

Batch Print All Attachments in Multiple Emails with Outlook VBA

Batch Print All Attachments in Multiple Emails

  1. At the very outset, launch your Outlook application.
  2. Then in the main window, press “Alt + F11” key buttons to access VBA editor.
  3. In the subsequent “Microsoft Visual Basic for Applications” window, open an empty module.
  4. Next copy the following VBA codes into such a module.
Sub BatchPrintAllAttachmentsinMultipleEmails()
    Dim objFileSystem As Object
    Dim strTempFolder As String
    Dim objSelection As Outlook.Selection
    Dim objItem As Object
    Dim objMail As Outlook.MailItem
    Dim objAttachments As Outlook.attachments
    Dim objAttachment As Outlook.Attachment
    Dim objShell As Object
    Dim objTempFolder As Object
    Dim objTempFolderItem As Object
    Dim strFilePath As String
 
    Set objFileSystem = CreateObject("Scripting.FileSystemObject")
    strTempFolder = objFileSystem.GetSpecialFolder(2).Path & "\Temp for Attachments " & Format(Now, "YYYY-MM-DD_hh-mm-ss")
    'Create a new temp folder
    MkDir (strTempFolder)
 
    Set objSelection = Outlook.Application.ActiveExplorer.Selection
 
    For Each objItem In objSelection
        If TypeOf objItem Is MailItem Then
           Set objMail = objItem
           Set objAttachments = objMail.attachments
 
           'Save all the attachments in the temp folder
           For Each objAttachment In objAttachments
               strFilePath = strTempFolder & "\" & objAttachment.FileName
               objAttachment.SaveAsFile (strFilePath)
 
               'Print all the files in the temp folder
               Set objShell = CreateObject("Shell.Application")
               Set objTempFolder = objShell.NameSpace(0)
               Set objTempFolderItem = objTempFolder.ParseName(strFilePath)
               objTempFolderItem.InvokeVerbEx ("print")
           Next objAttachment
        End If
    Next
End Sub

VBA Code - Print All Attachments in Multiple Mails

  1. Subsequently, you can add the new macro to the Quick Access Toolbar.
  2. After that, you ought to set your Outlook macro security level to low.
  3. Eventually you can have a try.
  • Firstly, in the mail list, select several emails whose attachments you want to print.
  • Then click on the new macro button in Quick Access Toolbar.
  • Next, all the attachments in the selected emails will be printed out.

Beware of Viruses Hidden in Macros

If you’ve configured your Outlook macro security level to low, you have to spend a lot of efforts blocking potential viruses in malicious macros. It’s because viruses can destroy your Outlook data in one go. Once your Outlook data is corrupt, you’ll try your best to recover Outlook data by all means, such as recurring to a potent 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 corrupt sql and outlook repair software products. For more information visit www.datanumen.com

Leave a Reply

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