是否可以在 MAILTO 链接的正文中添加 HTML 链接

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/247245/
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-28 22:36:38  来源:igfitidea点击:

Is it possible to add an HTML link in the body of a MAILTO link

htmlemailemail-integrationmailto

提问by StubbornMule

I have not had to mess with mailto links much. However I now need to add a link in the body of a mailto if it is possible.

我不必过多地处理 mailto 链接。但是,如果可能的话,我现在需要在 mailto 的正文中添加一个链接。

Is there a way to add a link or to change the email opened to an html email vs a text email?

有没有办法添加链接或将打开的电子邮件更改为 html 电子邮件与文本电子邮件?

Something like:

就像是:

<a href="mailto:[email protected]?body=The message's first paragraph.%0A%0aSecond paragraph.%0A%0AThird Paragraph.%0A%0ALink goes here">Link text goes here</a>

采纳答案by Alnitak

Section 2 of RFC 2368says that the bodyfield is supposed to be in text/plainformat, so you can't do HTML.

RFC 2368 的第 2 节说该body字段应该是text/plain格式的,所以你不能做 HTML。

However even if you use plain text it's possible that some modern mail clients would render a URL as a clickable link anyway, though.

但是,即使您使用纯文本,一些现代邮件客户端也可能会将 URL 呈现为可点击的链接,尽管如此。

回答by scunliffe

Add the full link, with:

添加完整链接,包括:

 "http://"

to the beginning of a line, and most decent email clients will auto-link it either before sending, or at the other end when receiving.

到一行的开头,大多数体面的电子邮件客户端会在发送之前自动链接它,或者在接收时在另一端自动链接它。

For really long urls that will likely wrap due to all the parameters, wrap the link in a less than/greater than symbol. This tells the email client notto wrap the url.

对于可能由于所有参数而包装的非常长的网址,请将链接包装在小于/大于符号中。这告诉电子邮件客户端不要包装 url。

e.g.

例如

  <http://www.example.com/foo.php?this=a&really=long&url=with&lots=and&lots=and&lots=of&prameters=on_it>

回答by GavinCattell

It isn't possible as far as I can tell, since a link needs HTML, and mailto links don't create an HTML email.

据我所知,这是不可能的,因为链接需要 HTML,而 mailto 链接不会创建 HTML 电子邮件。

This is probably for security as you could add javascript or iframes to this link and the email client might open up the end user for vulnerabilities.

这可能是出于安全考虑,因为您可以向此链接添加 javascript 或 iframe,并且电子邮件客户端可能会为最终用户打开漏洞。

回答by chanchal1987

Please check below javascript in IE. Don't know if other modern browser will work or not.

请在 IE 中检查以下 javascript。不知道其他现代浏览器是否可以工作。

<html>
    <head>
        <script type="text/javascript">
            function OpenOutlookDoc(){
                try {

                    var outlookApp = new ActiveXObject("Outlook.Application");
                    var nameSpace = outlookApp.getNameSpace("MAPI");
                    mailFolder = nameSpace.getDefaultFolder(6);
                    mailItem = mailFolder.Items.add('IPM.Note.FormA');
                    mailItem.Subject="a subject test";
                    mailItem.To = "[email protected]";
                    mailItem.HTMLBody = "<b>bold</b>";
                    mailItem.display (0); 
                }
                catch(e){
                    alert(e);
                    // act on any error that you get
                }
            }
        </script>
    </head>
    <body>
        <a href="javascript:OpenOutlookDoc()">Click</a>
    </body>
</html>

回答by Mike

Here's what I put together. It works on the select mobile device I needed it for, but I'm not sure how universal the solution is

这是我整理的。它适用于我需要的选定移动设备,但我不确定该解决方案的通用性

<a href="mailto:[email protected]?subject=Me&body=%3Chtml%20xmlns%3D%22http:%2F%2Fwww.w3.org%2F1999%2Fxhtml%22%3E%3C%2Fhead%3E%3Cbody%3EPlease%20%3Ca%20href%3D%22http:%2F%2Fwww.w3.org%22%3Eclick%3C%2Fa%3E%20me%3C%2Fbody%3E%3C%2Fhtml%3E">

回答by Kamlesh

I have implement following it working for iOS devices but failed on android devices

我已经在 iOS 设备上实现了它,但在 android 设备上失败了

<a  href="mailto:?subject=Your mate might be interested...&body=<div style='padding: 0;'><div style='padding: 0;'><p>I found this on the site I think you might find it interesting.  <a href='@(Request.Url.ToString())' >Click here </a></p></div></div>">Share This</a>

回答by hazmatzo

The specification for 'mailto' body says:

“mailto”正文的规范说:

The body of a message is simply lines of US-ASCII characters. The only two limitations on the body are as follows:

  • CR and LF MUST only occur together as CRLF; they MUST NOT appear independently in the body.
  • Lines of characters in the body MUST be limited to 998 characters, and SHOULD be limited to 78 characters, excluding the CRLF.

消息的正文只是几行 US-ASCII 字符。对 body 仅有的两个限制如下:

  • CR 和 LF 必须只作为 CRLF 一起出现;它们不得独立出现在体内。
  • 正文中的字符行必须限制为 998 个字符,并且应该限制为 78 个字符,不包括 CRLF。

https://tools.ietf.org/html/rfc5322#section-2.3

https://tools.ietf.org/html/rfc5322#section-2.3

Generally nowadays most email clients are good at autolinking, but not all do, due to security concerns. You can likely find some work-arounds, but it won't necessarily work universally.

通常,现在大多数电子邮件客户端都擅长自动链接,但出于安全考虑,并非所有人都如此。您可能会找到一些变通方法,但不一定普遍适用。