Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET app to send an mail with a hyperlink

Tags:

c#

.net

asp.net

MailMessage message = new MailMessage();
message.From = new MailAddress("[email protected]");

message.Subject = "Subject";
message.Body = "Please login";
SmtpClient smtp = new SmtpClient();

message.To.Add("[email protected]");                  
smtp.Send(message);

I want to have a hyperlink in the body of sent mail where it says "login". How can I do that?

like image 334
Karaman Avatar asked May 23 '12 12:05

Karaman


1 Answers

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;
like image 150
Lloyd Powell Avatar answered Oct 03 '22 01:10

Lloyd Powell