How can I open *.eml-files in compose mode for Mac OS X Mail? For Outlook "X-Unsent: 1" seems to do the trick, but does not work for Mac OS X Mail still opens in Read-Only.
2 Answers
This is a super old question, but obviously has received a fair number of views. My curiosity piqued, I figured I'd take a look. After some fiddling around, I found you can add the following header to make a message editable:
X-Uniform-Type-Identifier: com.apple.mail-draft
Add that to your otherwise RFC-2822 compliant message, give it a .eml
or .emlx
extension, and when you double-click it'll open as an editable message in Mail.app.
Have fun.

- 696
- 1
- 6
- 13
-
1Hey, why not share how I came to this conclusion. After opening Mail.app, I composed a new message in my iCloud account. I then opened Terminal.app and navigated to `~/Library/Mail/V3` and ran `find . -type f -mmin -3 | xargs ls -lrt`. In the last few entries I found my `.emlx` file. Opening that revealed a number of headers, and the one above was the most likely fit. I created a new `.eml` file from scratch, put in basic headers (Subject, From, To) and that test header, some content, then saved the file. It opened just like I wanted. – angrychimp Oct 19 '15 at 22:23
-
This didn't work for Gmail or Exchange accounts, because Mail.app added some additional .plist info that I couldn't find a formula for. In theory, you can use this to create a new message without a From entry, then select one when you open the file. – angrychimp Oct 19 '15 at 22:24
-
3Just tested in macOS 11 Big Sur but this no longer works. Double clicking .eml file and CMD + SHIFT + D seems to be the best work around. – catlan Feb 10 '21 at 16:42
In macOS Catalina 10.15.7, running the following commands from a Python script worked to open a new message and then switch to compose mode, but there is a race condition between opening the message and putting it in Compose mode if the osascript
command runs too quickly. The sleep
command is there to prevent the race, but you may need to adjust the length of sleep time to compensate for this. (I also used time.sleep(1)
in Python instead of the shell command.)
/usr/bin/open -a Mail path/to/tmp/message.eml
/bin/sleep 1
/usr/bin/osascript -e 'tell application "System Events" to tell application process "Mail"' -e 'keystroke "d" using {command down, shift down}' -e 'end tell'
Note that you must grant access to Terminal to control other apps, or the osascript
command will fail with an error. To do that, open System Preferences, click on the Security & Privacy item, click Accessibility from the left menu, click the lock icon to unlock the menu, then check the Terminal item (or add it if not listed) in the "Allow apps to control your computer." list.
Also note that the Cmd-Shift-D keyboard shortcut sends a message that is already in compose mode, so if someone is using Mail at the time the script runs, and they have a separate compose window in the foreground, then the script could send that message instead of putting the new message in compose mode.

- 179
- 3