1

我正在尝试实现在 EmailTo:body 中发送 URL 链接但遇到问题。

<a href="mailto:?subject=I’d like to share this page with you&amp;body=Check out this interesting information from ABCD Corporation: http%3a%2f%2flocalhost%2fResources%2fBlog%2fTest-Blog-2%2fOctober%2fLet’s-Abolish-Paper.aspx" title="Share this">Email</a>

但这会在 Outlook 中显示以下正文(特殊字符断开链接):

这是它的显示方式

但是,如果可以按以下方式生成主体,则可以对我有利:

这是它应该如何显示

我尝试了很多东西,但都没有成功。

谢谢

4

3 回答 3

2

我昨天也遇到了这个问题。这是我的解决方案,效果很好。

这里发生的确切情况是当我们对 url 编码进行编码时很好,但是由于 iis 或某些浏览器行为等许多因素,我们在 html 页面上加载或 Outlook 编码的 url 被解码。我所做的是我是双重编码。因此,当在 Outlook 上加载页面时,它只解码一次,一层编码仍然存在,我们得到了我们想要的。

根据您的代码:

var concatID = '&'+"Resource"'&'+"Blog"'&'+"Test-Blog-2"'&'+"October"'&'+"Lets-Abolish-Paper.Aspx";
var enocdedUrlAttr = encodeURIComponent(concatID);
var doubleEnCode = encodeURIComponent(enocdedUrlAttr);

现在,当您在浏览器中看到此内容时,您将获得所需的结果。附加您doubleEnCode的本地主机并制作网址。

于 2017-03-23T05:31:16.573 回答
0

Try this. You can still encode a straight quote mark into the email.

<a href="mailto:?subject=I’d like to share this page with you&amp;body=Check out this interesting information from ABCD Corporation:%0D%0A%0D%0Ahttp%3a%2f%2flocalhost%2fResources%2fBlog%2fTest-Blog-2%2fOctober%2fLet%27s-Abolish-Paper.aspx" title="Share this">Email</a>

Fiddle of Email Link

于 2014-01-24T15:00:18.440 回答
-2

要添加换行符,您需要使用%0D%0A您想要换行符(或两个)的位置。由于您的链接包含引号字符 - URL 中不允许使用 - 会破坏链接格式。

于 2014-01-24T14:55:18.443 回答