The following function will read an emlx file into Mathematica in a format compatible with examples that assume an EML format.
readEMLX[filename_String] := Module[ {instream},
ReadLine[instream = OpenRead[filename]];
Import[instream, {"EML", "FullMessageElements"}]
]
The emlx file format consists of a right space padded character representation of message length, the rfc822 message body immediately following (beginning on 'line 2'). At the end of the rfc822 message body and before EOF, is an Apple xml property list. The latter contains information used by Mail.app including read status and other 'interesting' information. If this information is necessary, it can be obtained by the following:
readEMLXXML[filename_String] := Module [ {instream
, sentinelString = "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">"},
Find[instream = OpenRead[filename], sentinelString];
Import[instream, "XML"]
]
This xml property list may be further processed using the approach discussed HERE.
It is important to note that if you wish to process the entirety of the plist XML embedded within the file, you must change the sentinelstring and pass ReadDTD-> "False" to Import . Unless this option in set, Mathematica fails when it encounters the DTD.
Also, within the property list is a field called flags which encodes the various statuses (read, answered, junk) as well as some numeric information. You can find more information about this as well as other parts of the emlx format from HERE.
As an aside, If someone writes an efficient/elegant/concise way to decode the flags, please post it here. I do have code to do this, yet its extremely ugly.
As I learn more about Mathematica and how to use it to integrate with Mail.app, I shall post it here.