Reputation: 3787
I send some message to email as below:
string link = "http://localhost:1900/ResetPassword/?username=" + user.UserName + "&reset=" + HashResetParams( user.UserName, user.ProviderUserKey.ToString() );
email.Body = link;
This string was sent to email, but shown as string, not as link, I want send it as link to click.
Upvotes: 8
Views: 46792
Reputation: 8818
string link = "<a href=http://localhost:1900/ResetPassword/?username=" + user.UserName + "&reset=" + HashResetParams( user.UserName, user.ProviderUserKey.ToString() + "> Link Text Here </a>");
It doesn't know that it's a link :)
Upvotes: 2
Reputation: 26396
Try this
string link = String.Format("<a href=\"http://localhost:1900/ResetPassword/?username={0}&reset={1}\">Click here</a>", user.UserName, HashResetParams( user.UserName, user.ProviderUserKey.ToString() ));
Upvotes: 10
Reputation: 3523
Changes the email body from Plain text to Html and generate the link using an <a>
element
string link = @"<a href="www.mylink.com">link</a>"
email.IsBodyHtml = true;
Upvotes: 2
Reputation: 58645
Make it a link with the a
HTML tag. And don't forget to set the MailMessage
as HTML body:
string link = "http://localhost:1900/ResetPassword/?username=" + user.UserName + "&reset=" + HashResetParams( user.UserName, user.ProviderUserKey.ToString() );
email.Body = "<a href='" + link + "'>" + link + "</a>";
email.IsBodyHtml = true;
Upvotes: 3
Reputation: 9154
Wrap link
in an anchor tag:
string link = '<a href="http://......">Click here to reset your password</a>';
and
email.IsBodyHtml = true;
Or combine them together using string concatenation and feed into email.Body
. An email body is HTML, so it wont be a link unless you tell it to be one. Also, don't forget to tell it that the body is HTML, like I always do.
Upvotes: 5