Print Automatically Attachments

Status
Not open for further replies.

Itmonitor

New Member
Outlook version
Outlook 2013 64 bit
Email Account
IMAP
Hi!

I use Outlook 2013 64 bit standalone with Windows 10 Anniversary Edition.

Up to now, when I receive pdf invoices in a certain email account, I need to open the email and print them manually. There is the usual Rules settings into Outlook 2013 that will print all the pdf files attached to received emails. But this is not a solution in my case.

I have an email account that is exclusively used to receive invoices from purchases. The invoices are in pdf format. However, upon purchase some suppliers also send automatically pdf files with standard information about product returns, and other legalities concerning the purchase I just did. Some have 10 pages or so. For this reason, if I set to print automatically all pdf attachments from emails received in this specific email account, it will result in a huge waste of paper, ink, not to say the time to sort out manually the invoices from the other printed pdf email attachments. Therefore, it defeats the purpose of streamlining the invoice printing process.

I thought about selecting the emails through their Subjects. In my case, we receive from suppliers in three countries in Europe. So the email Subjects can come as Invoice or Facture or Rechnung according to the language. I do not know if there is a way to do this email selection by email Subject.

Other idea is to limit the printing only to one page. Invoices in my case are always one page pdf. In this way, when I receive the other pdf documents (not invoices), even if they have manhy pages, Outlook would print only the first page. This will limit manual work to select the printed invoices from the other useless documents.

Well, this is the problem I am facing. Any advice is welcome! :)
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
Here's a sample for printing automatically:
Print Attachments Automatically - VBOffice

In the ItemAdd event replace the PrintAttachments line by:
if instr(Item.Subject,"Rechnung")>0 or instr(Item.Subject,"Invoice")>0 then
PrintAttachments Item
endif
(Extend the If statement to suit your needs.) Also, add ".pdf" to the case statement at the bottom.
 

Itmonitor

New Member
Outlook version
Outlook 2013 64 bit
Email Account
IMAP
Hi Michael, thank you for pointing out the VBA routine.

I did the modifications, but I am a newbie and still stuck with the points below:

1. The macro is marked in red at its first line, from Private Declare Functions until PrivatewithEvents line. This means I did something wrong or there is a bug in the macro.
2. I would need this macro to work only with one email account, not all email accounts in my Outlook 2013

I paste here the whole macro after my modifications. The macro instructions in italic are in red for me here on my side.

Any advice is welcome! :)

I.M.

Sub PrintAttachmentsPDF()
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

Private WithEvents Items As Outlook.Items


Private Sub Application_Startup()
Dim Ns As Outlook.NameSpace
Dim Folder As Outlook.MAPIFolder

Set Ns = Application.GetNamespace("MAPI")
Set Folder = Ns.GetDefaultFolder(olFolderInbox)
Set Items = Folder.Items
End Sub

Private Sub Items_ItemAdd(ByVal Item As Object)
If TypeOf Item Is Outlook.MailItem Then
If InStr(Item.Subject, "Rechnung") > 0 Or InStr(Item.Subject, "Invoice") > 0 Or InStr(Item.Subject, "Facture") > 0 Then
PrintAttachments Item
End If
End If
End Sub

Private Sub PrintAttachments(oMail As Outlook.MailItem)
On Error Resume Next
Dim colAtts As Outlook.Attachments
Dim oAtt As Outlook.Attachment
Dim sFile As String
Dim sDirectory As String
Dim sFileType As String

sDirectory = "C:\Users\xxxx\Desktop\xxx\Printed Email Invoices"

Set colAtts = oMail.Attachments

If colAtts.Count Then
For Each oAtt In colAtts

sFileType = LCase$(Right$(oAtt.FileName, 4))

Select Case sFileType
Case ".pdf"
sFile = ATTACHMENT_DIRECTORY & oAtt.FileName
oAtt.SaveAsFile sFile
ShellExecute 0, "print", sFile, vbNullString, vbNullString, 0
End Select
Next
End If
End Sub
End Sub
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
simply copy&paste the code as it is, and do only the mentioned modifications.
 
Status
Not open for further replies.
Thread starter Similar threads Forum Replies Date
D Print attachments automatically and moves the mail to a new folder Outlook VBA and Custom Forms 9
C automatically print attachments Using Outlook 4
5 Automatically print email attachments Using Outlook 7
J Automatically Print PDF When They Are Received Using Outlook 4
M Custom Calendar Print Suggestions? Using Outlook 0
M Print email and, attachments sent in hyperlinks in the email Outlook VBA and Custom Forms 2
A Day view - print appointment details Calendar Printing Assistant 1
I print calendar without subject and details Using Outlook 1
D Print Attachments only in selected emails using a macro Outlook VBA and Custom Forms 3
oliv- property "is printed" or catching print events Outlook VBA and Custom Forms 2
Diane Poremsky Print a list of your Outlook folders New Slipstick.com Articles 0
Diane Poremsky Combine and Print Multiple Outlook Calendars New Slipstick.com Articles 0
B Print list of previously sent recipients Using Outlook 1
R Print email message and attachment in order Outlook VBA and Custom Forms 2
L Outlook 2002: HTML Emails Will Not Print: Please Help Using Outlook 0
A Print first page of a new email Outlook VBA and Custom Forms 7
Diane Poremsky Print Monthly or Work Week Calendars New Slipstick.com Articles 0
Diane Poremsky No drop down calendars in Outlook 2010 Print Options New Slipstick.com Articles 0
Diane Poremsky Print Monthly or Work Week Calendars New Slipstick.com Articles 0
S Macro to print & move selected emails? Using Outlook 3
J Auto print PDF attachments as they arrive with certain words in subject Outlook VBA and Custom Forms 3
H Problems With Outlook 2013 VBA To Send and Print an email Outlook VBA and Custom Forms 1
D Outlook 2013 Categories won't print In color Using Outlook 2
G Calendar monthly view - Print just 3 weeks Calendar Printing Assistant 5
R Can't modify Outlook view font with IE anymore (even though IE still affects print font) Using Outlook 5
M Print Attachments from another mailbox (not default) Outlook VBA and Custom Forms 2
E Outlook VBA to print attached Pdf to a fax printer and assign fax number Using Outlook 0
L Outlook 2010 Quick Print Attachment, nothing happend Using Outlook 0
M button to send and print emails Using Outlook 26
S How to print ONLY first line of appointments in month view? Using Outlook 1
M print free/busy schedule of an user Using Outlook 2
O For Outlook 2007 - VBA to print attachments Using Outlook 1
W Cannot print Outlook 2007 emails Using Outlook 2
R problem with incomming e-mail I am unable to print full e-mail letter Using Outlook 1
M Custom print contacts Using Outlook 2
E Can't print from Outlook on wifi network Using Outlook 0
E can't print some retail discount coupons Using Outlook 7
J calendar print setup in outlook 2010 Calendar Printing Assistant 1
J Outlook 2010 using Quick Print to print attachments Using Outlook 1
D Use Outlook 2003 embedded imaged cannot print from the mail preview list Using Outlook 4
J Print next 7 days view of calendar (2010) Using Outlook 3
C Print all emails in a single folder with sent items Using Outlook 2
P Outlook closes down after clicking on the quick print icon. Using Outlook 3
I Outlook 2010 Print Created Date on Drafts Using Outlook 3
P Print multiple pocket calendars on one page Using Outlook 5
P Mail Merge vs Direct Mail Print BCM (Business Contact Manager) 4
A Print / View / Contacts Using Outlook 1
H Formatting of email conversation print outs - URGENT Using Outlook 1
A Outlook 11 for Mac won't print e-mail attachments Using Outlook 6
R Surely you can print details/Body? Calendar Printing Assistant 0
Similar threads


















































Top