简体   繁体   English

如何发送主题为 HTML 的 email

[英]How to send an email with subject in HTML form

I know how to send an email in html form using action mailto: in form element.我知道如何使用动作 mailto: 在表单元素中以 html 表单发送 email。 But this sends an email without the subject, How send an email with subject?但是这会发送一个没有主题的 email,如何发送一个有主题的 email?

 <a href="mailto:test@example.com?subject=Testing out mailto!">First Example</a>

More look here更多看这里

Its not clear in your question whether you want to automatically add when user click on the link or your code to send email is not email with subject.. You need to explain it more with code example.您的问题不清楚您是否要在用户单击链接时自动添加,或者您发送 email 的代码不是带有主题的 email。您需要用代码示例进行更多解释。

I am assuming you are asking for link this case you can use below code我假设你要求链接这种情况下你可以使用下面的代码

<a href="mailto:someone@yoursite.com?subject=Mail from Our Site">Email Us</a> 

Once use will click on link it will open link in default email client eg.一旦使用将点击链接,它将在默认 email 客户端中打开链接,例如。 outlook with email & subject line. outlook 和 email & 主题行。

You can add cc, bcc and even body text in such way below are some examples您可以通过以下方式添加抄送、密件抄送甚至正文文本,以下是一些示例

Adding CC and BCC添加抄送和密件抄送

Open default mail program, create new message with the TO, SUBJECT, CC, and BCC field already filled out.打开默认邮件程序,创建新邮件,收件人、主题、抄送和密件抄送字段已填写。 Essentially we are adding the parameters cc and bcc to the href value.本质上,我们将参数 cc 和 bcc 添加到 href 值。

Also note that you add multiple values to CC and BCC by comma separating them.另请注意,您通过逗号分隔将多个值添加到 CC 和 BCC。

<a href="mailto:someone@yoursite.com?cc=someoneelse@theirsite.com, another@thatsite.com, me@mysite.com&bcc=lastperson@theirsite.com&subject=Big%20News">Email Us</a>

Adding body text添加正文

Just add the body parameter into the ever-growing list of parameters we are using.只需将 body 参数添加到我们正在使用的不断增长的参数列表中。

 <h2>Basic</h2> <p><a href="mailto:someone@yoursite.com">Email Us</a></p> <h2>Adding a subject</h2> <p><a href="mailto:someone@yoursite.com?subject=Mail from Our Site">Email Us</a></p> <h2>Adding CC and BCC</h2> <p><a href="mailto:someone@yoursite.com?cc=someoneelse@theirsite.com, another@thatsite.com, me@mysite.com&bcc=lastperson@theirsite.com&subject=Big%20News">Email Us</a></p> <h2>Adding body text</h2> <p><a href="mailto:someone@yoursite.com?cc=someoneelse@theirsite.com, another@thatsite.com, me@mysite.com&bcc=lastperson@theirsite.com&subject=Big%20News&body=Body-goes-here">Email Us</a></p>

More details here更多细节在这里

I know how to send an email in html form using action mailto: in form element.我知道如何在 html 表单中使用操作 mailto: 在表单元素中发送 email。 But this sends an email without the subject, How send an email with subject?但这会发送一个没有主题的 email,如何发送一个带有主题的 email?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM