Currently I'm sending an HTML e-mail I'm creating out of asp.net strings is outputting links as plain text rather than hyperlinks, which is what I'm going for. The code for generating the e-mail string looks like this:
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);
}
}
What is the simplest way to do this?
Thanks!
Edit 1:
Tried -
string emailContent = "Plus, you may wish to bookmark <a href='" + link + "'>www.comparsave.com</a> for your rate comparison needs.";
Viewing the email source, the string is being html encoded by asp.net to render as plain text in html: < and > are being replaced by "& gt;" "& lt;" etc. How to stop asp.net from doing this??
Edit 2:
Okay, figured it out! Will post the answer later when I have time. Thanks all!