How do I convert .eml files to PDFs?

7,831

Here is an open-source tool that converts EML (MIME format) files to PDF. It does so by

parsing (and cleaning) the mime/structure, converting it to html and then using wkhtmltopdf to convert the generated html to a pdf file.

So you could either adapt the conversion process to HTML to your needs, or post-process the generated HTML file before it gets converted to PDF.

Share:
7,831

Related videos on Youtube

Clueless
Author by

Clueless

Updated on September 18, 2022

Comments

  • Clueless
    Clueless over 1 year

    I have almost 300 e-mails in .eml format that I need to convert or print to PDF for legal purposes. Because of that, I have some pretty specific needs:

    1. Must have page numbers.
    2. Must NOT have other headers/footers (especially not the path or current date).
    3. Must NOT show BCC recipients in the printout.
    4. Must have at least to, from, cc, and subject.
    5. Must not display user/profile/account name across the top (a la Microsoft Outlook Memo style)
    6. Filename must be the subject of the email, with some kind of unique index inserted or appended to prevent overwrites.

    What I've tried so far (and why it didn't work):

    1. Printing to PDF from Outlook. Always prints with my name at the top. I accidentally discovered at home that if you open the files with no account set up, you can print them individually with no name. But there doesn't seem to be any way to import them into Outlook itself to print them all at once, or, at least, in larger batches than one at a time. Even if I were inclined to print them one at a time, the job name/filename that Outlook seems to default to for print-to-file jobs is "Microsoft Outlook -- Memo Style" which is no good.

      Side note: I have access to three different PDF printers at home: Microsoft Print to PDF, Foxit Reader, and PDFCreator. MSPTP doesn't offer a default filename at all, and the other two use the one I mentioned above.

    2. Import them into a Thunderbird local folder using importexporttools add- on. This may be my best bet, but the issue that drives me nuts more than should be able to use importexporttools again to save the files, en masse, to PDF, but any I save to PDF in this way have the default headers/footers on them. I have scoured the config files and set up inside and outside of Tbird and I cannot for the life of me find where it's getting that setting from. The alternative is to save all 300 one by one by one. But even if I'm up for that, Tbird prints either scant headers (I think it consisted of from, date, subject on print.show_header = 0) or the whole thing-- there's no inbetween. Frustratingly, no difference between "normal" headers (1) and full headers (2)-- they both seem to print the full header. So if I go this route, I will have to go through and manually remove any BCC lines from the PDFs from about half of them, give or take.

    3. (Added since original post) Changing the extension to mht and opening in Internet Explorer. Tried opening in Firefox, too, for good measure, and Chrome. IE looked good, and the footers and headers were formattable, but all the email headers were completely missing. Firefox wouldn't even open it, handled it like a download, and Chrome it was just the plain text of the body on one long line, no formatting, and no headers. Just to cover all my bases, I tried the eml files in all three browsers, nothing.

    Anyone have any ideas?

    • Bagus Tesa
      Bagus Tesa about 7 years
      if my memory serves me right, you could rename eml file into mht and print them using (the best browser ever) internet explorer... never tried for e-mails from outlook/thunderbird though..
  • Gabor
    Gabor about 5 years
    An easier solution for non-Windows users: you can forward the email to your Gmail and from gmail's web interface you can save it as a pdf.
  • Erwann
    Erwann about 2 years
    @Gabor but you'd have to do this one email at a time, no?