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


当前回答

<a href="mailto:manish@simplygraphix.com?subject=Feedback for 
webdevelopersnotes.com&body=The Tips and Tricks section is great
&cc=anotheremailaddress@anotherdomain.com
&bcc=onemore@anotherdomain.com">Send me an email</a>

您可以使用此代码设置主题,正文,抄送,密件

其他回答

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

如果你想添加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编码的。

mailto:joe@company.com?subject=Your+subject
<a href="mailto:manish@simplygraphix.com?subject=Feedback for 
webdevelopersnotes.com&body=The Tips and Tricks section is great
&cc=anotheremailaddress@anotherdomain.com
&bcc=onemore@anotherdomain.com">Send me an email</a>

您可以使用此代码设置主题,正文,抄送,密件