As far as I know this did not work pre-Yosemite.
This script will create a new DRAFT styled-text (HTML) message.
You used to have to send it immediately to get it to work — or so it was thought — would someone still using Mavericks test this script for me?
I noticed today using Mail on 10.10.4 that I could save, close, and reopen it and retain the formatting.
Unfortunately I can't figure out a way to reopen it for editing via normal AppleScript.
I think I'll have to resort to Keyboard Maestro or System Events to do that.
So it's still kludgey, but it's doable.
-------------------------------------------------------------------------------------------
# Auth: Mark Munro (Macscripter)
# dCre: 2013/08/04 01:09
# dMod: 2015/08/12 18:25
# Appl: Mail
# Task: Make new HTML email!
# Tags: @Applescript, @Script, @Mail, @New, @Message, @HTML, @Content
-------------------------------------------------------------------------------------------
set toName to "Addressee Name"
set textSubject to "HTML Test"
set textBody to "<HTML>
<BODY bgcolor=\"#99CCFF\">
<H1>Hi There</H1>
<p>This is very minimal <u>\"hello world\"</u> HTML document.</p>
</BODY>
</HTML>"
mailMessageCreate(toName, toAddress, textSubject, textBody)
-------------------------------------------------------------------------------------------
--» HANDLERS
-------------------------------------------------------------------------------------------
on mailMessageCreate(toName, toAddress, textSubject, textBody)
tell application "Mail"
activate
set refMessage to make new outgoing message with properties {subject:textSubject, visible:false} -- visible MUST be false to work
tell refMessage
set html content to textBody -- must set the _HTML CONTENT_ rather than the _CONTENT_
make new to recipient at end of to recipients with properties {name:toName, address:toAddress}
save
end tell
close front window
end tell
end mailMessageCreate
-------------------------------------------------------------------------------------------