ASP.NET app to send an mail with a hyperlink

前端 未结 5 1473
滥情空心
滥情空心 2020-12-18 03:31
MailMessage message = new MailMessage();
message.From = new MailAddress(\"hkar@gmail.com\");

message.Subject = \"Subject\";
message.Body = \"Please login\";
SmtpCli         


        
相关标签:
5条回答
  • 2020-12-18 03:56
    message.Body = string.Format("Click <a href='{0}'>here</a> to login", loginUrl);
    
    0 讨论(0)
  • 2020-12-18 04:00
    message.Body = "Please <a href=\"http://www.example.com/login.aspx\">login</a>";
    

    Make sure you highlight when sending that the content is HTML though.

    message.IsBodyHTML = true;
    
    0 讨论(0)
  • 2020-12-18 04:01

    Format the message as HTML and make sure to set the IsBodyHtml property on the MailMessage to true:

    message.IsBodyHtml = true;

    0 讨论(0)
  • 2020-12-18 04:03
     System.Text.StringBuildersb = new System.Text.StringBuilder();
     System.Web.Mail.MailMessage mail = new System.Mail.Web.MailMessage(); 
     mail.To = "recipient@address"; 
     mail.From = "sender"; 
     mail.Subject = "Test"; 
     mail.BodyFormat = System.Web.Mail.MailFormat.Html;
     sb.Append("<html><head><title>Test</title><body>"); //HTML content which you want to send
     mail.Body = sb.ToString();
     System.Web.Mail.SmtpMail.SmtpServer = "localhost"; //Your Smtp Server 
     System.Web.Mail.SmtpMail.Send(mail); 
    

    You just have to set the format of body to html then you can add html element within the bosy of mail message

    0 讨论(0)
  • 2020-12-18 04:05

    Set the message to message.IsBodyHTML = true

    <a href="http://YourWebsite.Com">Login</a>
    
    0 讨论(0)
提交回复
热议问题