tags:

views:

151

answers:

3

Hi

I want to open the user's Mail client on clicking a button and populate the message body with some HTML content.

While my code successfully does that (using mailto: URL scheme), the HTML content shows up as is (i.e. the HTML is not formatted).

Is there a way I can specify that my message contains HTML when opening the Mail app? Or can I format my data like we do when typing an email in a mail client?

Thanks.

+1  A: 

while specific extensions might be available on certain mailto handlers, the relevent text from RFC 2368 - The mailto URL scheme is

The "body" hname should contain the content for the first text/plain body part of the message.


The hname here refers to the 'body' in the 'body=some text' part of the mailto url. You basically get to provide a full set of email headers (name=value pairs) in the mailto url - separated by &'s - 'body' is defined specifically in the rfc to indicate the following text (up until the next separating '&') is the text/plain part of the message. Because there is no schema to add multiparts to an email message, you cannot express the multipart required to add the text/html part.

The only way to add a text/html part to the message would require you to be using a mailto handler that either supported an extended uri syntax, or had some way to allow you to continue programmatically adding content to the email.

Chris Becke
Read through the specs but couldn't really make out what you're referring to here by hname.
lostInTransit
Did you try ⌘F? “‘hname’ and ‘hvalue’ are encodings of an RFC 822 header name and value, respectively.”
Peter Hosey
Yes I did. And from what I could understand this would only work for to, cc, bcc, subject and body.
lostInTransit
Correct. Read the last paragraph of the answer.
Peter Hosey
+1  A: 

I'm not sure about this, but just to give some input. RFC2368 Shows how to format mailto links, specifically how to include headers. One example of a header is "Content-type", which you would want to set to text/html in this case. So something like

mailto:?Content-type=text/html

might just work.

tmadsen
Nope. Doesn't work.
lostInTransit
A: 

I answered that a couple days ago here: How can I send a HTML email from Cocoa?

catlan