Html 如何使用 Mailto URL 发送带有主题的邮件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1093925/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 00:09:22  来源:igfitidea点击:

How to send mail with a Subject using a Mailto URL?

htmlurimailto

提问by Sampson

I need to make a Mailto linkto my website which is suppose to contain either the product name or the product page URL in the subject section. How can I do it?
Exp: When you get an email through eBayabout a product you are selling or buying, you automatically know what product that email is about by seeing the product name in the subject section.
How can i do this?

我需要在Mailto link我的网站上创建 .a 文件,该网站假设在subject section. 我该怎么做?
Exp:当您收到一封eBay关于您正在销售或购买的产品的电子邮件时,您会通过查看主题部分中的产品名称自动知道该电子邮件是关于什么产品的。
我怎样才能做到这一点?

回答by Fuji727

I've run into problems with this before when I didn't url encode the value, so I would suggest (using lc's example):

我之前遇到过这个问题,当我没有对值进行 url 编码时,所以我建议(使用 lc 的例子):

<a href="mailto:[email protected]?subject=This+Is+My+Product">

or

或者

<a href="mailto:[email protected]?subject=This%20Is%20My%20Product">

回答by lc.

This page [Link Dead]outlines the syntax of mailto URIs:

此页面 [Link Dead]概述了 mailto URI 的语法:

  • Address message to multiple recipients

    ,   (comma separating e-mail addresses)
    
  • Add entry in the "Subject" field

    subject=Subject Field Text
    
  • Add entry in the "Copy To" or "CC" field

    [email protected]
    
  • Add entry in the "Blind Copy To" or "BCC" field

    [email protected]
    
  • Add entry in the "Body" field

    body=Your message here
    
    Within the body use "%0A" for a new line,
    use "%0A%0A" for a new line preceded by a blank line (paragraph),
    
  • 向多个收件人发送消息

    ,   (comma separating e-mail addresses)
    
  • 在“主题”字段中添加条目

    subject=Subject Field Text
    
  • 在“复制到”或“抄送”字段中添加条目

    [email protected]
    
  • 在“Blind Copy To”或“BCC”字段中添加条目

    [email protected]
    
  • 在“正文”字段中添加条目

    body=Your message here
    
    Within the body use "%0A" for a new line,
    use "%0A%0A" for a new line preceded by a blank line (paragraph),
    

What you are looking for is:

您正在寻找的是:

<a href="mailto:[email protected]?subject=This Is My Product">

Note, it's probably a good idea to URL encode the spaces with either a +or a %20:

请注意,使用 a+或 a对空格进行 URL 编码可能是个好主意%20

<a href="mailto:[email protected]?subject=This+Is+My+Product">

回答by Stefan Mai

<a href="mailto:[email protected]?subject=YourSubjectHere">Try This</a>

If you want something more advanced, you're going to have to code it from scratch (or use someone else's script). Try looking into PHP, ASP.NET, Ruby on Rails, etc.

如果您想要更高级的东西,您将不得不从头开始编写代码(或使用其他人的脚本)。尝试研究 PHP、ASP.NET、Ruby on Rails 等。