Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
323 views
in Technique[技术] by (71.8m points)

html - 我可以使用mailto:设置电子邮件的主题/内容吗?(Can I set subject/content of email using mailto:?)

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

  ask by Jiew Meng translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Yes, look all tips and tricks with mailto: http://www.angelfire.com/dc/html-webmaster/mailto.htm

(是的,请使用mailto查看所有提示和技巧: http : //www.angelfire.com/dc/html-webmaster/mailto.htm)

mailto subject example:

(mailto主题示例:)

 <a href="mailto:[email protected]?subject=free chocolate">example</a> 

mailto with content:

(mailto内容:)

 <a href="mailto:[email protected]?subject=look at this website&body=Hi,I found this website and thought you might like it http://www.geocities.com/wowhtml/">tell a friend</a> 

As alluded to in the comments, both subject and body must be escaped properly.

(正如评论中提到的那样, subjectbody必须适当地转义。)

Use encodeURIComponent(subject) on each, rather than hand-coding for specific cases.

(在每种情况下都使用encodeURIComponent(subject) ,而不是对特定情况进行手工编码。)

As Hoody mentioned in the comments, you can add line breaks by adding the following encoded sequence in the string:

(如Hoody在评论中所述,您可以通过在字符串中添加以下编码序列来添加换行符:)

%0D%0A // one line break

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...