HellorhighWater
HellorhighWater

Reputation: 15

How to put a link in an email

When i send Forgot password mail to user to reset their password my mail & link is like this:

<br><br>You have forgotten your password so here is a link to reset it:<br>
www.bla.com/test/ResetPasswordVertification?VertificationCode=ojlqidsgkxERoPy6vCQHZtJ9jLRaYA

But i Want something like this : You have forgotten your password Click here to reset it

I Tried to add an <a>-tag :

.Send("Reset Password ", "You have forgotten your password\n so here is link to reset it \n <a href=\"www.bla.dk/Account/loginResetPasswordVertification?VertificationCode=\">Click her</a>" 
    + user.VertificationCode 
    + "\n <br/> Best Regards \n ", 
    Email);
<br>

But My Result is like this:

You have forgotten your password Click here =asdawdasdawdadw

The Code:

new MailHandler().Send("Reset Password", "You have forgotten your password \n so here is a link to reset it \n www.bla.com/test/ResetPasswordVertification?VertificationCode=" + user.VertificationCode, Email);

Upvotes: 0

Views: 109

Answers (3)

Sol W
Sol W

Reputation: 110

.Send("Reset Password ", $"You have forgotten your password\n so here is link to reset it \n <a href=\"www.bla.dk/Account/loginResetPasswordVertification?VertificationCode=\{user.VertificationCode}">Click here</a>" + "\n <br/> Best Regards \n ", Email); <br>

Upvotes: 0

Sol W
Sol W

Reputation: 110

Put the closing quote and the </a> tag after the user verification code.

Upvotes: 0

Pranay Rana
Pranay Rana

Reputation: 176886

if you want to sent html based email than you have to do like this

string href = String.Format(@"www.bla.com/test/ResetPasswordVertification?VertificationCode={0}", user.VertificationCode);
msg = new MailMessage("[email protected]",
                "[email protected]", "Message from PSSP System",
                "You have forgotten your password<br/> "+
                "so here is link to reset it<br/>" +
                "<a href='"+ href +"'>click here !</a>");

msg.IsBodyHtml = true;

you need to set flag IsBodyHtml

Upvotes: 2

Related Questions