开发者

Cocoa - specify content type in mailto URLs to include HTML

开发者 https://www.devze.com 2022-12-14 01:04 出处:网络
I want to open the user\'s Mail client on cli开发者_运维知识库cking a button and populate the message body with some HTML content.

I want to open the user's Mail client on cli开发者_运维知识库cking 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.


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.


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消