Somebytes SoftwareSomebytes Software Development


Print Exchange attachments directly

How can I print Exchange attachments (PDF) ?

Today more and more invoices are coming by mail, with EEAttachments you get a handy service which can further process these for you. In this section I will show how to print PDF files directly if they are arriving in your Exchange-Mailbox.

You need a program, which can process PDF files. I use the Sumatra PDF in this example.

With this command you can print a PDF file by Sumatra PDF:

sumatrapdf.exe -print-to-default -silent zuDruckendeDatei.pdf

or if you want to select the printer you can use:

sumatrapdf.exe -print-to "DruckerName" -silent zuDruckendeDatei.pdf

In order to use it by EEAttachments you can enter this line into the field "Run for attachment" followed by %file% as the argument or you can enter a batch file which can do some more with your file, for example it could delete it afterwards.

This is the content of our print_and_delete.bat, in which you have to change the path to your copy of Sumatra PDF.

D:\temp\sumatrapdf.exe -print-to-default %1
del %1 /q

Print PDF attachments from Exchange

In order to give "EEAttachments" or any other windows service access to the printer you should start the service as another user as you can read here.