C # how to send an email containing a hyperlink using System.Net.Mail?

0

I have created a class to send you emails using the System.Net.Mail library.

To make the sending format the HTML message. The message I'm sending is as follows:

<div style="display: block; margin-left: auto; margin-right: auto; width: 600px; font-family:Calibri,sans-serif;">
    <p>Olá Aluno,</p>
    <p>Recebemos uma solicitação para redefinir sua senha de acesso ao sistema MEUSISTEMA.</p>
    <p style="color:#1762aa; font-size:18px"><a href="www.MEUSISTEMA.com/ResetPassword?RecoverCode=893P7IN83FXO5UO2WASHTQI65LCP792O">Clique aqui para redefinir sua senha. </a></p><br>
    <p><strong style="font-size:18px">Importante: </strong>O link para redefinição de senha tem validade de 1 hora. Após este período será necessário gerar um novo link.</p>
</div>

The sending is being done correctly, however when I open the email to check the message that was sent, the hyperlink is strange:

  

Hello Student,

     

We received a request to reset your MEUSISTEMA system access password.

     

[www.MEUSYSTEM.com/ResetPassword?RecoverCode=V3A8AZ379JZIWSTPXZK6HT90Y8BIZYYZ] Click here to reset your password.

     

Important: The password reset link is valid for 1 hour. After this period you will need to generate a new link.

What would be the way to fix this?

    
asked by anonymous 03.04.2018 / 01:25

1 answer

0

Place the link as follows:

<a href=\"http://www.MEUSISTEMA.com/ResetPassword?RecoverCode=893P7IN83FXO5UO2WASHTQI65LCP792O\">Clique aqui para redefinir sua senha.</a>

Notice the counter bar added \ at the beginning and end of the link and the http:// at the beginning.

And make sure your MailMessage object has the following property set to true :

IsBodyHTML = true;

Example:

MailMessage email = new MailMessage();
email.IsBodyHTML = true;
    
03.04.2018 / 12:42