This post content is only to show you how to handle attachments in a VBA code , you can print your attachments in many other ways as well, but here you can learn how to do outlook VBA attachments handling.
(this post's screen shots were taken from Microsoft Outlook 2003)
The instructions:
Outlook -> Click Alt-F11 to open the VBA Editor
Or use “Tools” Menu - “Macro” - “Visual Basic Editor”

Right Click The "Project1" Line And Select Insert Module

In the new added module (if it’s your first module then it is named by default “Module1”) paste the following code:
AVG products are running on over 80 million computers worldwide, find out why.
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 printall()
Dim CurrentMailItem As MailItem
Dim attCounter As Integer
Dim loopCounter As Integer
Dim attFileName As String
Dim errMsg As String
On Error GoTo err
CurrentMailItem = Application.ActiveInspector.CurrentItem
attCounter = CurrentMailItem.Attachments.Count
For loopCounter = 1 To attCounter
attFileName = CurrentMailItem.Attachments.Item(loopCounter).FileName
CurrentMailItem.Attachments.Item(loopCounter).SaveAsFile( _
Environ$("TEMP") & "\" & attFileName)
ShellExecute(0, "print", Environ$("TEMP") & "\" & attFileName, "", "", 1)
Kill(Environ$("TEMP") & "\" & attFileName)
DoEvents()
Next
Exit Sub
err:
IIf(attFileName <> "", errMsg = "Last file handeld was : " & _
attFileName & ".", errMsg = "No file was handeld.")
MsgBox("Error printing all attachments." & vbCrLf & errMsg & _
vbCrLf & vbCrLf & err.Description, vbCritical, "Error number " & _
err.Number)
Save the module and Close the VBA Editor.
Open any received mail message.
Right Click one of the toolbars and select “Customize…”

Drag the “Project1.printall” Macro to one of your toolbars

Change the new button name and icon

Close the message.
How to use it:
Open the message with the attachments
Click your new button and all your attachments (at the current opened item) will wait for you at your printer tray.
Pay attention:
You will print only to the last printer used by outlook.
Wonderful, this could be a start.
ReplyDeleteWhat I would like to add is a line in the header giving the attachment's name plus pages/page number or "x of z", or whatever.
This would make it for the reader transparent, whoever prints it usually is not the one who has to deal with it. That's why.