How to convert .eml to .pdf file

How to convert .eml file to .pdf file. Original file (.eml) is an email message. It has a html content (pictures and colors), and I need to save the original formatting.

Now the file is saved locally like this >>

C:\RPAtemp\Downloads\file_name_here.eml

What you want to save locally is the .BodyAsHTML. Then use this procedure to convert it to PDF:

Start by saving the email’s BodyAsHTML to a file.
 
Then assign that file’s path and filename to the HTMLFile variable.
 
Then assign the path and filename of your desired output PDF file to OutputFile.
 
Then use Start Process:

The first property is the path to Chrome.exe – on my machine it’s “C:\Program Files\Google\Chrome\Application\chrome.exe”

For the arguments:

"--headless --disable-gpu --print-to-pdf=""" & OutputFile & """ " & """" & HTMLFile & """"

The issue with using Chrome headless to generate the PDF is you likely won’t get the images. Here is how to update the HTML to embed the images. These instructions are for MSG files but it could be converted to work for EML files.

@ext-o
Right now, I haven’t found a straightforward way to save an .eml file as a PDF while keeping its original layout. If Outlook is installed on your machine, you can use the “Start Process” activity in UiPath to open the .eml file with Outlook. Then, use the shortcut Ctrl + P to print and save it as a PDF.