Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 24th, 2012  |  syntax: None  |  size: 1.13 KB  |  hits: 22  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. ASP.NET app to send an mail with a hyperlink
  2. MailMessage message = new MailMessage();
  3.                 message.From = new MailAddress("hkar@gmail.com");
  4.  
  5.                 message.Subject = "Subject";
  6.                 message.Body = "Please login";
  7.                 SmtpClient smtp = new SmtpClient();
  8.  
  9.                 message.To.Add("karaman@gmail.com");                  
  10.                 smtp.Send(message);
  11.        
  12. message.Body = "Please <a href="http://www.example.com/login.aspx">login</a>";
  13.        
  14. message.IsBodyHTML = true;
  15.        
  16. <a href="http://YourWebsite.Com">Login</a>
  17.        
  18. System.Text.StringBuildersb = new System.Text.StringBuilder();
  19.  System.Web.Mail.MailMessage mail = new System.Mail.Web.MailMessage();
  20.  mail.To = "recipient@address";
  21.  mail.From = "sender";
  22.  mail.Subject = "Test";
  23.  mail.BodyFormat = System.Web.Mail.MailFormat.Html;
  24.  sb.Append("<html><head><title>Test</title><body>"); //HTML content which you want to send
  25.  mail.Body = sb.ToString();
  26.  System.Web.Mail.SmtpMail.SmtpServer = "localhost"; //Your Smtp Server
  27.  System.Web.Mail.SmtpMail.Send(mail);
  28.        
  29. message.Body = string.Format("Click <a href='{0}'>here</a> to login", loginUrl);