Batch print PDF attachments in Outlook

A lot of us receive emails with PDF attachments (eg: invoices, faxes, etc), where we want to open the email and print the attachment.  This can be a time consuming task, and I was looking for a way to automate.

I found this site which was very helpful, however it didn’t quite work for me so I have made some changes and explained further how to configure this below.

Firstly, you need all the emails you want to print to be in a single folder.  Create a new folder directly under your Personal Folders – right click on Personal Folders and then click “New Folder”  In my example below, I have called this folder ..To Print

Secondly, create a new folder called .Printed this is where the emails are moved to after the attachments are printed.

You can either move emails manually to this folder by dragging and dropping them (if you receive ad-hoc emails from different senders), or you can create an Outlook Rule to move all emails from particular senders into your “To Print” folder.

Now, to print automatically batch print all those PDF’s in that folder, do the following:

Step 1:  Create a Visual Basic Macro

Open Outlook, click Tools – Macro – Visual Basic Editor
Click Insert – Module
Highlight the code below, press CTRL-C to copy it then click into your empty Module1 and press CTRL-V to paste it
Close the Visual Basic Editor

Public Sub PrintAttachments()
    Dim Inbox As MAPIFolder
    Dim Item As MailItem
    Dim Atmt As Attachment
    Dim FileName As String
    Dim i As Integer

    Set Inbox = GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Parent.Folders.Item("..To Print")
    Set Printed = GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Parent.Folders.Item(".Printed")

    For Each Item In Inbox.Items
        For Each Atmt In Item.Attachments
            FileName = "C:\Temp\" & Atmt.FileName
            Atmt.SaveAsFile FileName
            Shell """C:\Program Files\Adobe\Reader 9.0\Reader\acrord32.exe"" /h /p """ + FileName + """", vbHide
        Next
    Item.Move Printed
    Next

    Set Inbox = Nothing
End Sub
Some notes about the code above:
You can change the name of the “..To Print” and “.Printed” folders.  I have put a fullstop in front of them so they appear at the top of my folder list (as Outlook displays in alphabetical order).  If you create a different folder name, just change the name in the code above.
The folder where you put those emails (waiting to print) needs to be created off your main Personal Folders (not from within your Inbox).   Have a look at the image below to see what I mean:

Example of folders created to store emails you want to batch print

Lastly, I put a nice icon on my taskbar so I don’t always have to run the Macro from within the Tools menu.

Right click up on the toolbar (where all your icons are)
Left Click on Customize

Click the Commands tab

Click on Macros on the left hand side

Click and drag “Project1.PrintAttachments” up to your toolbar.  A little black vertical bar will display as you drag it, and when it is positioned where you want the icon to be, let go of the mouse button.  You will now have a new button called “Project1.PrintAttachments”

Right click on that new button and click Default Style - this will take away the text and you will have a strange triangle icon.

Right click on that new icon and click Change Button Image, and choose an icon you like.

Click Close

You now have an icon in your taskbar.  Click it and all the PDF attachments are automtically printed and then moved to your printed folder.

Enjoy!


About these ads
This entry was posted in Adobe Acrobat, Batch Print PDF Attachments, Outlook. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s