Is it possible to apply CSS style in the method of sending e-mail?

1

I have the following method that sends a password recovery email to the user. I would like to know if it is possible to apply some type of CSS formatting in it, in order to make the email sent more attractive.

Email Received:

Code:

publicvoidEnviarEmailRedefinicaoSenha(intCodigo){try{stringempresa=_config.GetValue<string>("EmpresaEmail");
                Clientes objClientes = new Clientes(_config).ConsultarClientes(Codigo);
                Data = DateTime.Now.AddMinutes(10).ToString("HH:mm:ss");
                this.Assunto = "Redefinição de senha";//Assunto,
                StringBuilder BodyContent = new StringBuilder();

                Link = "<a href =http://" + Link + "/Accounts/RedefinicaoSenha?id=" +
                    PCIGlobal.Encrypt(Codigo.ToString(), _config.GetValue<string>("keyEncryption")) +
                    "&T=" + PCIGlobal.Encrypt(Data, _config.GetValue<string>("keyEncryption")) +
                    ">Clique aqui</a>";

                BodyContent.Append("Prezado(a) " + objClientes.CliNome + ", ");
                BodyContent.Append("<br/>");
                BodyContent.Append("<br/>");
                BodyContent.Append("Você solicitou a redefinição da sua senha de acesso ao Escritório Virtual.");
                BodyContent.Append("<br/>");
                BodyContent.Append("Não se preocupe, o processo é simples, basta clicar no link abaixo e seguir as instruções.");
                BodyContent.Append("<br/>");
                BodyContent.Append(Link);
                BodyContent.Append("<br/>");
                BodyContent.Append("<br/>");
                BodyContent.Append("Qualquer problema entre em contato conosco.");
                BodyContent.Append("<br/>");
                BodyContent.Append("<br/>");
                BodyContent.Append("Atenciosamente,");
                BodyContent.Append("<br/>");
                BodyContent.Append("Equipe <b>" + empresa + "</b>");



                this.Mensagem = BodyContent.ToString();
                this.EnviarEmail();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    
asked by anonymous 06.03.2018 / 15:29

1 answer

4

Just to stay as a record I'll post my comment in reply. So you can end the question if you think you've solved your problem.

Yes it is possible to use direct CSS in Tag. Any indexed style sheet will be ignored by most SMTP, something like this should work:

BodyContent.Append("<p style="font-size:16px; color:red;">Você solicitou a redefinição da sua senha de acesso ao Escritório Virtual.</p>");

The above code would be the same as: p {font-size:16px; color:red;} in .css

Here are two links in Portuguese that can help you with good CSS practices for email

link link

    
06.03.2018 / 17:14