Solved

Printing attachments with their respective messages in Outlook

Posted on 2011-03-05
1
384 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 250 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

SuperAntiSpyware Licenses Discounted by 25% !

Exclusive offer to Experts Exchange Members!
Buy SuperAntiSpyware License(s) from us and save 25% on the regular purchase price.
- Includes Full SuperAntiSpyware Vendor Support Entitlements
- Your Subscription does not begin until you activate your license
- Buy for your friends

Question has a verified solution.

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

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Many people use more than one email account and so it becomes difficult for them to manage them when they use separate accounts,  so, in this article, I have shared an easy way to add Other Mail Accounts in your Google Inbox. It helps to combine all…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

739 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