Search code examples
c#href

How to render links inside of strings


I having troubles with passing a link to my string, I use something like this but the message comes with the link and I don't want that, I just want the "aqui" word, so when I click on them should redirect me to the link...

Does anyone know why this happening?

 message.Body = new TextPart("plain")
                    {
                        Text = $"Olá,\n\nAgradecemos pela seu registo na Plataforma de Gestão Departamental do Instituo Politécnico de Bragança.\nClique <a href=\"{HtmlEncoder.Default.Encode(ctokenlink)}\">aqui</a> para completar o registo!\n\n"
                    };

Problem


Solution

  • Try creating the TextPart with the "html" subtype instead of the "plain" subtype. Also consider using the BodyBuilder class to create your email. This allows you to have both the html and the plain text fallback.

    http://www.mimekit.net/docs/html/T_MimeKit_BodyBuilder.htm