In El Capitan, the support for “set html content to myhtml” seem to be not functioning correctly. When I do that in the script below, the myhtml is included with the email but the header of the email message say “Content-Type: text/plain; charset=us-ascii” rather then "Content-Type: multipart/alternative; boundary=“Apple-Mail=_B09C9239-C6AF-4DD3-9B79-671528EAE1E1"”. The result is the the receiver can not see the html content.
Maybe I can set the header by manually, but I’m having trouble with the syntax. Please advice.
set toName to "ward@cyane.com"
set toAddress to "ward@cyane.com"
set textSubject to "HTML Test3"
set myheader to "Content-Type: multipart/alternative; boundary=\"Apple-Mail=_B09C9239-C6AF-4DD3-9B79-671528EAE1E1\""
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}
--Set new to receipient to header with properties myheader (..or something like that)
-- send
end tell
end tell
end mailMessageCreate