Print EMLs programmatically

Has anyone achieved achieved printing EMLs saved by the Save Mail Message activity without interacting with GUI?

I have a process with the following steps;

  • Get all emails from Inbox in a list
  • Sort emails by date received
    Get Exchange Mail Messages appears to get emails from newest to oldest
    – I perform this step to sort them from oldest to newest for business process reasons
  • For each each email
  • For each attachment
  • If attachment name ends in “pdf”
  • Get email date header and convert to string in local date format so will print with EML (doesn’t by default)
  • Save Mail Message
  • Invoke PowerShell to Start-Process localFolder + “tempEmail.eml”

At this stage I use Send Hot Key to pass CTRL+P then a Click activity to click the print button, Delay for one second then Close Window to close the email.

While this usually works, it often fails stopping the whole process because of a misclick on the Print button or a contact pop up from hovering over an Outlook contact too long. Therefore, has anyone achieved printing EML files programmatically?

In click button, check the Simulate click property. It will do the operation in background without hover. :grinning: