具有HTML正文的mailto链接

本文翻译自:mailto link with HTML body

I have a couple of mailto links in a HTML document. 我在HTML文档中有几个mailto链接。

<a href="mailto:etc...">

Can I insert HTML formatted body in the mailto: part of the href ? 我可以在hrefmailto:部分插入HTML格式的正文吗?

<a href="mailto:me@me.com?subject=Me&body=<b>ME</b>">Mail me</a>

Note that (2016) in iOS, it is perfectly fine to add <i> and <b> tags for simple italic, bold formatting. 请注意,在iOS中(2016),为简单的斜体,粗体格式添加<i><b>标签是完全可以的。


#1楼

参考:https://stackoom.com/question/Na6O/具有HTML正文的mailto链接


#2楼

Whilst it is NOT possible to use HTML to format your email body you can add line breaks as has been previously suggested. 尽管无法使用HTML格式化电子邮件正文,但可以按照先前的建议添加换行符。

If you are able to use javascript then "encodeURIComponent()" might be of use like below... 如果您能够使用javascript,则“ encodeURIComponent()”可能会像下面这样使用...

var formattedBody = "FirstLine \n Second Line \n Third Line";
var mailToLink = "mailto:x@y.com?body=" + encodeURIComponent(formattedBody);
window.location.href = mailToLink;

#3楼

It is worth pointing out that on Safari on the iPhone, at least, inserting basic HTML tags such as <b> , <i> , and <img> (which ideally you shouldn't use in other circumstances anymore anyway, preferring CSS) into the body parameter in the mailto: does appear to work - they are honored within the email client. 值得指出的是,至少在iPhone上的Safari上,插入了<b><i><img>类的基本HTML标签(理想情况下,您无论如何也不应在其他情况下使用它们,更喜欢CSS)放入mailto:的body参数中mailto:确实起作用-它们在电子邮件客户端中很受好评。 I haven't done exhaustive testing to see if this is supported by other mobile or desktop browser/email client combos. 我尚未进行详尽的测试,以查看其他移动或桌面浏览器/电子邮件客户端组合是否支持此功能。 It's also dubious whether this is really standards-compliant. 这是否真的符合标准也值得怀疑。 Might be useful if you are building for that platform, though. 但是,如果您正在为该平台构建,可能会很有用。

As other responses have noted, you should also use encodeURIComponent on the entire body before embedding it in the mailto: link. 正如其他响应所指出的那样,在将其嵌入到mailto:链接之前,还应该在整个主体上使用encodeURIComponent。


#4楼

As you can see in RFC 6068 , this is not possible at all: 如您在RFC 6068中所看到的,这是完全不可能的:

The special <hfname> "body" indicates that the associated <hfvalue> is the body of the message. 特殊的<hfname> “ body”表示关联的<hfvalue>是消息的正文。 The "body" field value is intended to contain the content for the first text/plain body part of the message. “正文”字段值旨在包含消息的第一个文本/纯文本正文部分的内容。 The "body" pseudo header field is primarily intended for the generation of short text messages for automatic processing (such as "subscribe" messages for mailing lists), not for general MIME bodies. “正文”伪头字段主要用于生成用于自动处理的短消息(例如,用于邮件列表的“订阅”消息),而不是用于一般的MIME正文。


#5楼

可以输入unicode值以插入换行符(即\ ),但是HTML标签具有不同程度的支持,应避免使用。


#6楼

Some things are possible, but not all, say for example you want line breaks, instead of using <br /> use %0D%0A 有些事情是可能的,但不是全部,例如您要换行,而不是使用<br />使用%0D%0A

Example: 例:

<a href="mailto:?subject=&body=Hello,%0D%0A%0D%0AHere is the link to the PDF Brochure.%0D%0A%0D%0ATo view the brochure please click the following link: http://www.uyslist.com/yachts/brochure.pdf"><img src="images/email.png" alt="EMail PDF Brochure" /></a>                        
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值