当我使用mailto:时,是否可以设置电子邮件的主题/内容?


当前回答

如果你想添加html内容到你的电子邮件,url编码你的html代码的消息体,并包括在你的mailto链接代码,但问题是你不能设置电子邮件的类型从明文到html,客户端使用链接需要他们的邮件客户端默认发送html电子邮件。如果你想测试的话,这里有一个简单的mailto链接的代码,链接中包含一个图像(添加angular风格的url是为了可见性):

<a href="mailto:?body=%3Ca%20href%3D%22{{ scope.url }}%22%3E%3Cimg%20src%3D%22{{ scope.url }}%22%20width%3D%22300%22%20%2F%3E%3C%2Fa%3E">

html标记是url编码的。

其他回答

诀窍在这里 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>

注意,根据RFC 2368,不能在消息体中使用HTML:

特殊名称“body”表示关联的hvalue是消息体。“body”名称应该包含消息的第一个文本/纯正文部分的内容。mailto URL主要用于生成短文本消息,这些消息实际上是自动处理的内容(例如邮件列表的“订阅”消息),而不是一般的MIME体。

来源:https://stackoverflow.com/a/13415988/1835519

您可以使用以下任何一种方式向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>

如何添加主题到邮件标签

mailto:joe@company.com?subject=Your+subject