Outlook macro to print cover email as well as the attachments:

I have a macro that works great with the exception that it doesn't print the cover page of the emails along with the attachments. Need some help getting the email to print with the attachments as well.


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 PrintAttachment()
Dim myItems, myItem, myAttachments, myAttachment As Object
Dim myOrt As String
Dim myOlApp As New Outlook.Application
Dim myOlExp As Outlook.Explorer
Dim myOlSel As Outlook.Selection
Dim strFile As String
'Set destination folder
myOrt = "C:\Program Files\Microsoft Office\"
On Error Resume Next
Set myOlExp = myOlApp.ActiveExplorer
Set myOlSel = myOlExp.Selection
For Each myItem In myOlSel
Set myAttachments = myItem.Attachments
If myAttachments.Count > 0 Then
For i = 1 To myAttachments.Count
myAttachments(i).SaveAsFile myOrt & myAttachments(i).DisplayName
strFile = myOrt & myAttachments(i).DisplayName
ShellExecute 0&, "print", strFile, 0&, 0&, 0&
Next i
End If
Set myItems = Nothing
Set myItem = Nothing
Set myAttachments = Nothing
Set myAttachment = Nothing
Set myOlApp = Nothing
Set myOlExp = Nothing
Set myOlSel = Nothing
End Sub

Open in new window

Who is Participating?
David LeeCommented:
Hi, pover.

Add this line


somewhere after line #22 and before #25.
poverAuthor Commented:
thank you, that did the trick.
David LeeCommented:
You're welcome.  Glad I could help.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.