当我使用mailto:时,是否可以设置电子邮件的主题/内容?
当前回答
注意,根据RFC 2368,不能在消息体中使用HTML:
特殊名称“body”表示关联的hvalue是消息体。“body”名称应该包含消息的第一个文本/纯正文部分的内容。mailto URL主要用于生成短文本消息,这些消息实际上是自动处理的内容(例如邮件列表的“订阅”消息),而不是一般的MIME体。
来源:https://stackoverflow.com/a/13415988/1835519
其他回答
是的,看看所有的提示和技巧mailto: http://www.angelfire.com/dc/html-webmaster/mailto.htm
邮件主题示例:
<a href=“mailto:no-one@snai1mai1.com?主选=免费巧克力">example</a>
邮件内容:
<a href="mailto:no-one@snai1mai1.com?subject=看这个网站&body=嗨,我发现了这个网站,认为你可能会喜欢它http://www.geocities.com/wowhtml/">告诉一个朋友</a>
正如注释中提到的,主体和主体都必须正确转义。使用encodeURIComponent(subject),而不是针对特定情况手工编码。
正如Hoody在评论中提到的,你可以通过在字符串中添加以下编码序列来添加换行符:
%0D%0A // one line break
mailto:joe@company.com?subject=Your+subject
您可以使用以下任何一种方式向mailto命令添加已添加的主题。 将?subject outmailto添加到mailto标签。
<a href="mailto:test@example.com?subject=testing out mailto">First Example</a>
我们还可以将文本添加到消息体中,方法是在标记的末尾添加&body,如下面的示例所示。
<a href="mailto:test@example.com?subject=testing out mailto&body=Just testing">Second Example</a>
除正文外,用户还可以输入&抄送或&密件抄送来填写抄送和密件抄送字段。
<a href="mailto:test@example.com?subject=testing out mailto&body=Just testing&cc=test1@example.com&bcc=test1@example.com">Third
Example</a>
如何添加主题到邮件标签
诀窍在这里 http://neworganizing.com/content/blog/tip-prepopulate-mailto-links-with-subject-body-text
<a href="mailto:tips@neworganizing.com?subject=Your+tip+on+mailto+links&body=Thanks+for+this+tip">tell a friend</a>
我把它分成几行,让它更容易读。
<a href="
mailto:johndoe@gmail.com
?subject=My+great+email+to+you
&body=This+is+an+awesome+email
&cc=janedoe@gmail.com
&bcc=billybob@yahoo.com
">Click here to send email!</a>