[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Printing attachments with their respective messages in Outlook

Posted on 2011-03-05
1
Medium Priority
?
396 Views
Last Modified: 2012-05-11
The macro posted with: http://www.experts-exchange.com/Software/Office_Productivity/Groupware/Outlook/Q_22933400.html?sfQueryTermInfo=1+10+30+attach+email+macro+outlook+print

does not print pdf attachments. In case of one email with 3 .jpg attachments, it printed one of them twice and skipped another.  I would appreciate fixes to these.  Is it possible to add a pause option after printing each email or attachment, and ask for an input to continue?

Thank you.
0
Comment
Question by:fl160
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 76

Accepted Solution

by:
David Lee earned 1000 total points
ID: 35049294
Hi, fl160.

Try this version.  This uses a different method to print Acrobat files and pauses after each item.
Private Declare Function ShellExecute Lib "shell32.dll" _
  Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, _
  ByVal lpFile As String, ByVal lpParameters As String, _
  ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long


Sub PrintMessageAndAttachments()
    Dim olkMsg As Outlook.MailItem, _
        olkAtt As Outlook.Attachment, _
        objShell As Object, _
        strFilename As String, _
        strCommandLine As String
    
    Set objShell = CreateObject("WScript.Shell")
    
    For Each olkMsg In Application.ActiveExplorer.Selection
        '--- Print the message ---'
        olkMsg.PrintOut
        '--- Print the attachments ---'
        For Each olkAtt In olkMsg.Attachments
            strFilename = Environ("Temp") & "\" & olkAtt.FileName
            olkAtt.SaveAsFile strFilename
            Select Case LCase(Right(olkAtt.FileName, 3))
                Case "pdf"
                    'Change the printer name on the next line'
                    strCmdLine = "AcroRd32.exe /t """ & strFilename & """ ""HP Deskjet 3320"""
                    objShell.Run strCmdLine, 0, False
                Case Else
                    ShellExecute 0&, "print", strFilename, 0&, 0&, 0&
            End Select
        Next
        If msgbox("Do you want to continue printing items?", vbQuestion + vbYesNo, "Print Message and Attachments") = vbNo Then
            Exit For
        End If
    Next
    
    'Cleanup'
    Set objShell = Nothing
    Set olkAtt = Nothing
    Set olkMsg = Nothing
End Sub

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you looking for the options available for exporting EDB files to PST? You may be confused as they are different in different Exchange versions. Here, I will discuss some options available.
With so many activities to perform, Exchange administrators are always busy in organizations. If everything, including Exchange Servers, Outlook clients, and Office 365 accounts work without any issues, they can sit and relax. But unfortunately, it…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question