This script converts .emlx
and .partial.emlx
files written by Apple’s Mail.app into fully self-contained, “stand alone” .eml
files which can be imported and opened by a great variety of email applications (Mail.app, Thunderbird, …).
Apple uses these formats for internal storage (see ~/Library/Mail/V4
), and under normal circumstances you will not come in contact with those files. Unfortunately, one of my IMAP mailboxes went out of service and I was not able to copy all the messages to a different account with Mail.app, even though all mails and attachments were there (see here for the story).
That’s why I created this script.
Installation with package manager
This is the easiest way if you’re not a developer. Use a current version of Node.js (currently built and tested with v10.15.3 LTS) and run the following command to install the script globally with npm:
Then, run the script with at least two arguments: (1) Path to the directory which contains the .emlx
and .partial.emlx
files, (2) path to the existing directory where the results should be written to.
Optionally, you can specify --ignoreErrors
as third argument. This way, the conversion will not be aborted in case there’s an error for a file (see the log output for details in this case).
Build
2 days ago - Many people try to export EMLX to EML in order to transfer emails from Mac Mail to Windows Live Mail. EMLX is a data file of Mac Mail. Jump to Move EML Files to MBOX, PST, EMLX - The Mac EML Converter application transfer EML files with high certainty level. It is saving time.
Use a current version of Node.js (currently built and tested with v10.15.3 LTS). Install the dependencies, run the tests, and compile the TypeScript code with yarn or npm:
Releasing to NPM
![How How](https://www.uslsoftware.com/wp-content/uploads/convert-emlx-to-eml-2.png)
Commit all changes and run the following:
… where <update_type>
is one of patch
, minor
, or major
. This will update the package.json
, and create a tagged Git commit with the version number.
About the file formats
Disclaimer: I figured out the following by reverse engineering. I cannot give any guarantee about the correctness. If you feel, that something should be corrected, please let me know.
.emlx
and .partial.emlx
are similar to .eml
, with the following peculiarities:
.emlx
These files start with a line which contains the length of the actual .eml
payload:
The number 2945
denotes, that the actual .eml
payload is 2945 characters long, starting from the second line.
At the end, these files contain an XML property list epilogue, which holds some Mail.app-specific meta data. Using the given character length at the file’s beginning, this epilogue can be stripped away easily and an .eml
file can be created.
Edit: Later, I found those additional sources, which basically confirm my findings:
.partial.emlx
Mail.app uses this format to save emails which contain attachments. Attachments are saved as separate, regular files relative to the .partial.emlx
file. Afaik, Apple does this due to Spotlight indexing.
Mail.app’s internal file structure looks as follows (nested into two further hierarchies of directories named with number 0 to 9):
1234
is obviously the email’s ID. The Attachments
directory contains the raw attachment files, whereas Messages
contains the messages stripped of their attachments (and .emlx
files, for messages which did not contain any attached files in first place).
The subdirectories 1.2
and 2
in above’s example are numbered according to their positions within the corresponding email’s Multipart hierarchy.
To convert a .partial.emlx
file into an .eml
file, the separated attachments need to be re-integrated into the file.
Credits
Without the following modules I would probably be still working on this script (or have given up on the way). Thank you for saving me so much time!
Beside that, here are some resources which I found very helpful during development:
Contributing
Pull requests are very welcome. Feel free to discuss bugs or new features by opening a new issue. In case you submit any bug fixes, please provide corresponding test cases and make sure that existing tests do not break.
Copyright (c) 2018, 2019 Philipp Katz
Change the extension to view it in a browser. EML files are very similar to MHTML, and changing the file extension to *.mht will quickly convert it into a format that can be opened in Internet Explorer. While other web browsers can open MHT files, Internet Explorer is the only one which will format them correctly. This method won't allow you to download any attachments.- Enable file extensions if you have them hidden. In Windows 8, you can check the 'File name extensions' box in the View tab of any Explorer window. In older versions of Windows, open the Control Panel and select Folder Options. Click the View tab and uncheck 'Hide extensions for known file types'.
- Right-click on the EML file and select 'Rename'.
- Delete the .eml extension and replace it with .mht. Windows will warn you that this could cause problems with the file. Confirm that you want to change the extension.
- Open the file in Internet Explorer. This will usually be the default program for MHT files. You can right-click the file, select 'Open with', and then choose Internet Explorer from the list. Internet Explorer will display the MHT file in virtually the same format as the EML file would appear in a mail client.