目前,我正在发送一封 HTML 电子邮件,我正在使用 asp.net 字符串将链接输出为纯文本而不是超链接,这正是我想要的。生成电子邮件字符串的代码如下所示:
Uri link = new Uri("http://www.somesite.com");
string body = "Plus, you may wish to bookmark " + link + " for your rate comparison needs."
string subject = Resources.Email.VerificationEmailSubject;
Email.SendEmail(email, subject, body);
public static void SendEmail(string toAddress, string subject, string body)
{
try
{
MailMessage mailMessage = new MailMessage();
mailMessage.To.Add(new MailAddress(toAddress));
mailMessage.Subject = subject;
mailMessage.IsBodyHtml = true;
mailMessage.Body = body;
using (SmtpClient smtpClient = new SmtpClient())
{
smtpClient.Send(mailMessage);
}
}
catch (Exception ex)
{
LogManager log = new LogManager();
log.LogError(typeof(Email), ex);
}
}
最简单的方法是什么?
谢谢!
编辑1:
试过 -
string emailContent = "Plus, you may wish to bookmark <a href='" + link + "'>www.comparsave.com</a> for your rate comparison needs.";
查看电子邮件源,该字符串正在被 asp.net 编码为 html 中的纯文本:< 和 > 被替换为“& gt;” "<" 等如何阻止asp.net这样做?
编辑2:
好的,想通了!稍后我有时间会发布答案。谢谢大家!