The officially official Devuan Forum!

You are not logged in.

#1 2024-05-13 22:35:18

alexkemp
Member
Registered: 2018-05-14
Posts: 314  

EML / MHT Files Convert to RTF: Help Required

I've got a large number (101) of .eml files and wish to be able to convert them into .rtf files. My searching throws up a very large number of online websites to convert them (no thanks!) but I cannot find a Linux-friendly method.

Reason for Conversion

The 101 EML files have been sourced from Thunderbird-hosted emails. I wish to be able ultimately to place each one into a bundle of PDFs for supply to a UK District County Court "Document Upload Centre". The workload for that is:-

  • EML => Libreoffice => PDF

If LO was able to load the EML files as HTML / EHTML (which is essentially what they are) then there would be no need for help, but currently LO loads each EML file as plain text. If I can convert the EML files into RTF files (as one example) then that would fix my problem.

I've actually already got each file also in a PDF format (obtained via Print in Thunderbird), but to easily be able to create a "PDF Bundle" will need to be able to load them into LO Writer.

Help

EML files were originated by Microsoft and are Plain-Text files in MIME-format. They essentially have the identical format to MHT / MHTML files, which was an early MS-derived format for saving a webpage in a single-page format (it was originated in the days of Internet Explorer).

Last edited by alexkemp (2024-05-14 12:38:28)

Offline

#2 2024-05-13 23:32:59

soren
Member
Registered: 2023-04-30
Posts: 128  

Re: EML / MHT Files Convert to RTF: Help Required

Pandoc might be able to handle this in some way, not sure but worth investigating.

I did find this program which may help, a Perl mail-to-HTML converter.

https://www.mhonarc.org/ Its in debian repos under bookworm too.
https://packages.debian.org/bookworm/mhonarc

So once the emails are converted to html you could build a pdf file from them??

Last edited by soren (2024-05-13 23:36:21)

Offline

#3 2024-05-14 00:34:58

alexkemp
Member
Registered: 2018-05-14
Posts: 314  

Re: EML / MHT Files Convert to RTF: Help Required

Thanks for that soren. I did investigate Pandoc but it does not mention EML at any point.

I work under Daedalus:

$ apt search mhonarc
Sorting... Done
Full Text Search... Done
mhonarc/stable 2.6.19-2.2 all
  Mail to HTML converter

$ apt info mhonarc
Package: mhonarc
Version: 2.6.19-2.2
Priority: optional
Section: mail
Maintainer: Jeff Breidenbach <jab@debian.org>
Installed-Size: 7,601 kB
Depends: perl:any
Recommends: libdigest-md5-perl
Tag: implemented-in::perl, interface::commandline, interface::web,
 mail::list, role::program, use::converting, use::organizing,
 use::storing, works-with-format::html, works-with::mail,
 works-with::text
Download-Size: 847 kB
APT-Sources: http://deb.devuan.org/merged daedalus/main amd64 Packages
Description: Mail to HTML converter
 MHonArc is a Perl mail-to-HTML converter. MHonArc provides HTML mail
 archiving with index, mail thread linking, etc; plus other capabilities
 including support for MIME and powerful user customization features.

I'm about to go to bed, so this waits until tomorrow. Many thanks for taking the time & trouble to help.

Offline

#4 2024-05-14 06:41:55

pcalvert
Member
Registered: 2017-05-15
Posts: 199  

Re: EML / MHT Files Convert to RTF: Help Required

Have you tried opening them with Chromium? I just tried opening an MHT file in Firefox, but it didn't work; however, Firefox suggested using Chromium so I tried that and it worked.


Freespoke is a new search engine that respects user privacy and does not engage in censorship.
Another one is called Luxxle.

Offline

#5 2024-05-14 07:46:22

alexkemp
Member
Registered: 2018-05-14
Posts: 314  

Re: EML / MHT Files Convert to RTF: Help Required

Thunderbird uses Firefox to display itself on the screen. That's how you can be absolutely certain that Firefox can display MHT files (I've written my own, and they display fine). I am using firefox-esr 115.10.0esr-1~deb12u1.

PS
Trying to open an EML file in Firefox gives an option to open it in Thunderbird / Save to disk; not helpful. Chromium just displays the text content, and ignores all formatting / embedded content; also not helpful.

PPS
The issue is not to be able to *open* the file. The issue is to be able convert it into a format that LO Writer can open & display.

Thanks for trying to help.

Offline

#6 2024-05-14 08:13:24

ralph.ronnquist
Administrator
From: Battery Point, Tasmania, AUS
Registered: 2016-11-30
Posts: 1,198  

Re: EML / MHT Files Convert to RTF: Help Required

Offline

#7 2024-05-14 08:19:16

alexkemp
Member
Registered: 2018-05-14
Posts: 314  

Re: EML / MHT Files Convert to RTF: Help Required

I've now installed mhonarc & used it in anger. It does exactly the job that it professes to do (the following is from info mhonarc):

NAME
       mhonarc - convert mail/news messages to HTML

SYNOPSIS
       mhonarc [options] [arguments]

DESCRIPTION
       MHonArc is a Perl program for converting mail, or news, messages into HTML archives.  MHonArc can also be used to convert
       individual messages into HTML documents.

       The documentation for MHonArc is distributed in HTML format.  Due to its size and organization, it is not suited for
       manpage format.  Consult your system administrator for where the documentation has been installed, or see "AVAILABILITY" on
       where you can access the documentation on the web.

<snip>

The following produces a single-page HTML file + saves "pdfwD701WIjT3.pdf" in the same directory (that is the attached PDF in the email). The HTML opens in Writer just fine (I do not think much of the default display choices, but that is a personal issue). The HTML has an embedded link that can open the attachment (no direct use for the PDF bundle):

$ mhonarc -single 2023-05-26-0418.eml > 2023-05-26-0418.html

So, so far mhonarc looks to be a viable option.

Offline

#8 2024-05-14 09:42:34

soren
Member
Registered: 2023-04-30
Posts: 128  

Re: EML / MHT Files Convert to RTF: Help Required

So once you have converted them all into html files via mhonarc you can batch process them via pandoc. Libre Office Writer is probably not going to make the html files look very good and even worse when exported to pdf.

This is what i did to 3 of my email files to test. Doing it single file is going to be painful if you have over 100 emails to process, maybe a shell script of some kind could be adapted ??

mhonarc -single 1.eml > 1.html
mhonarc -single 2.eml > 2.html
mhonarc -single 3.eml > 3.html
pandoc --pdf-engine=weasyprint -o file.pdf *.html

This gave me a pdf file that was fairly similar to what the html and .eml file should look like and this is those 3 emails exported to one pdf file. Their is probably more switches in pandoc that could be used to format the pdf document better. I didnt use emails with attachments so not sure about that.

Last edited by soren (2024-05-14 09:44:14)

Offline

#9 2024-05-14 10:03:55

soren
Member
Registered: 2023-04-30
Posts: 128  

Re: EML / MHT Files Convert to RTF: Help Required

Or if you already have the .eml files as .pdf files like you said as you printed them off thunderbird then use pdfunite to merge them into one pdf file like so. Just make sure to backup the files first before you do these commands and do them from a different directory.

pdfunite *.pdf out.pdf

pdfunite is part of poppler-utils.

https://manpages.debian.org/bookworm/po … .1.en.html

Offline

#10 2024-05-14 12:34:35

alexkemp
Member
Registered: 2018-05-14
Posts: 314  

Re: EML / MHT Files Convert to RTF: Help Required

Hi soren

Yeah, I had already looked at finding utilities such as pdfunite & may well end up using that. My main reason for NOT going that route is the following phrase in the most recent Order that I've received:

e. Documents required for a hearing should be in electronic form. PDF format, indexed, paginated and bookmarked.

It may well be possible to do that with  pdfunite but the point for me was that LibreOffice can do it using Master Documents.

Also this:

f. For guidance on what is required see:- https://www.judiciary.uk/announcements/ … t-bundles/
g. For help in how to do this see https://st-philips.com/creating-and-usi … g-bundles/

I'm still in the process of learning how to use Master Documents, and I need to reduce all this new stuff if I'm ever going to get it all sorted in time.

I've made an early test with a Master Document and, frankly, it's a breeze. There will be lots of detail that will need sorting, but there is a solution in sight by going this route.

As you say, it needs a quick batch file to sort all those EML files.

Thanks for your input, soren - a lifesaver.

Offline

Board footer