Print all files in a folder

excel
pdf
outlook
activities

#1

Hello,

I have been trying for some time now to print all the attachments in an inbox on my outlook account.
It works okay, however, I want to see if I can find a more reliable method. That didn’t require those manual clicks (right click attachment, pressing print). This isn’t accurate enough.

I want it also to run in the background, so if I was able to utilise get outlook mail message -> save attachment -> (Some kind of print activity). Any suggestions?

Today I use get outlook to find all the messages, then press the top mail, click attachment, click print, move mail to different folder. Repeat the process.

I have looked into rules in Outlook also. But I would have to make my own script to print attachments.

Suggestions?

Thanks


フォルダにあるファイルを繰り返し印刷
#2

Hi @Smith93 - did you manage to achieve this? I’m also having the same issue.

Thanks


#3

Hello.

No, I didn’t…


#4

Hey @Olivia & @Smith93

Do you just want background automation of your process - meaning using Simulate Click and minimized window of Outlook or let’s say fully background - via API maybe?

For the second option there is no Print activity for now I think mostly because it depends a lot on the document type that you want to print - from what I’ve understood while reading some articles related to this.

For reference:
https://stackoverflow.com/questions/12918698/which-windows-print-api-to-call-from-net-program - “Er, those are fancy doc types!! It sounds like you are looking for Windows API functions that can print Word and Excel documents. Is that right? Anyway, no such functions exist. You need Word and Excel. Or a 3rd party library like Aspose. No 3rd party library will do the job as well as the original app though” - this is what some users say.

https://msdn.microsoft.com/en-us/library/windows/desktop/dd162959(v=vs.85).aspx

So I think you can achieve the fully background automation but it would need much more research and testing than what I did.

My suggestion would be to make use of the background automation we currently have (with Simulate option).

Thanks,
Viorela


#5

@ovi @Smith93

Hi both,

What I wanted was to just be able to send a print command to a printer queue on my network. We found a way to do this in the end.

In UiPath, we used ‘Invoke power shell’ activity and the command used is “print /d:\<ServerName><ShareName> filename”


How to Send Files to Printer Queue
#6

Thanks for sharing your solution, Olivia.


#7

Hi Olivia.

Could you please provide your XAML as I am not having success reproducing your solution.

Thanks

EDIT: For future web searches, a solution I found for bulk printing PDFs in a directory is;

  • Directory.GetFiles(targetFolder, “*.pdf”) to get an array of strings containing the file paths
  • For each string in array
  • Remove spaces from file path string
  • Start process FileName “C:\Program Files (x86)\SumatraPDF\SumatraPDF.exe” with Arguments "-print-to-default " + filePath

Note this is dependent on;

  • Having SumatraPDF install (free and open source)
  • File path not have any spaces as I had trouble getting SumatraPDF to take file paths with spaces in it. If anyone finds a fix for this, please share.

I hope it helps.


#9