Apple Mail - Compose HTML email with AppleScript?

Hi all,

I posted a topic last night asking if Postbox for Mac could compose HTML email from AppleScript - it appears that it can’t.

Can Apple Mail (on 10.8.2) compose an HTML email using AppleScript? I know how to send a message, but if I put HTML in it, the markup just comes through as the content of the message body and the Content-Type is text/plain (needs to be text/html).

The dictionary doesn’t show me anything to do with encoding, headers or message format so I’m hoping I’ve just missed something.


Operating System: Mac OS X (10.8)

Maybe just an idea, why not using telnet to communicate the old fashion way with a mail server?

There are tons of ways I could do this, but the idea is to use the mail app that’s already installed without having to worry about whether or not telnet is installed/enabled, having to configure an SMTP server, etc.

In a perfect world I’d use Postbox but since that doesn’t seem to support HTML email from AppleScript, I’m trying If that doesn’t work, I could try telnet or another mail client (a small one that does support AppleScript HTML email, if I can find one).

You’re right, though - telnet would definitely work. :slight_smile:

Operating System: Mac OS X (10.8)


Make an rtf document with paragraphs viand the styles and such visible, so you can copy them while you edit your mail.

You can start off with a mail html, or make the html with TextEdit.

Be sure that there are no resources in the html, that you don’t provide online, like images and such, and adjust any links to look towards them accordingly.

Once you have your template proper you can write a script that:

tells text edit to open the rtf document.

copies the contents of it to the clipboard

closes it

makes a new Message in Mail

and pastes in the contents of the clipboard.

Well I was suggesting it because every out of the box mac is installed with telnet. The web is full of bash scripts using telnet for sending emails. Using those scripts and AppleScript you can send mails within a minute. Also the other thing is that the body of the mail can be composed by yourself instead of an fancy interface messing op your mail body like Apple Mail does. For instance Mail like to send an mail with attachment like images, which can give you problems with highly secured networks. With those scripts the body of the mail is only text and images will be downloaded when the mail is rendered on the client’s screen.

Sending html mail with mail app is really a kluge when not using a dedicated template for (Lots of free ones out there.) So this is definitively something at least I will look into!

I ended up using PHP (which I know well) - it works perfectly and I don’t need AppleScript. That was my preference in the first place, although I had hoped would accept AppleScript as an option for easily sending HTML email. That didn’t end up being the case, unless I’ve missed something obvious.

Thanks for the replies. :slight_smile:

If you are still interested, I posted a method to do so here:

However, I am trying to figure out how to then add an attachment to it which fails…