邮件正文中的Mailto链接

用户名

我在vb.net中有一个要求,例如Outlook邮件正文应包含一个链接。单击该链接后,将打开另一个邮件项目,其中包含“收件人”列表和“抄送”列表。我正在使用以下代码,

 string Body = "";
 Body += "Please, click the below link to view the details. %0D%0D"
 Body += "<a href=mailto:" + cc + "?Subject=" + Subject + "> Click here to Approve </a>"
 sMsg = User.Redirect("mailto:" + cc + "?Subject=" + Subject + "&body=" + Body)
 ScriptManager.RegisterStartupScript(Me.Page, Me.GetType(), "showalert", sMsg, True)

但是我没有在Outlook中正确获取链接。它显示如下,

Please, click the below link to view the details. 
<a href=mailto:[email protected]?Subject=DCW Trucking Ltd.> Click here to Approve </a> 

我只需要“单击此处批准为链接”。

我不应该使用Outlook dll。

鲁法诺夫

首先-您应将地址括在双引号中:

Body += "<a href=\"mailto:" + cc + "?Subject=" + Subject + "\"> Click here to Approve </a>"

因为当前它是无效的HTML标签。

其次-您应该将此Body变量用作邮件的HTML正文,而不是文本正文。

由于它是遗留的ASP.NET重定向到mailto地址,因此该地址的“ body”参数中的字符应进行Url编码(使用HttpUtility.UrlEncode方法),因此生成的重定向链接应如下所示:

mailto:[email protected]?subject=Meow&body=Please%2C%20click%20the%20below%20link%20to%20view%20the%20details.%0A%3Ca%20href%3D%22mailto%3Atest%40example.com%3Fsubject%3DMeow%22%3EClick%20here%20to%20Approve%3C%2Fa%3E

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章