How to get "x_" from Html tags in outlook with ASPNET

1

I have the following problem when sending an email with my application, at the time of opening the email, the Outlook provider modifies the template tags by placing the "x _" at the beginning of the name and id attributes of the tag. Home For example a normal input would look like this: <input type="text" name="nome" />. Home But it looks like this when it arrives in the inbox: <input type="text" name="x_nome" /> .

Has anyone ever had a similar problem?

My Email Submission class:

 public static class MailHelper
    {

        private static string Login = ConfigurationManager.AppSettings["LoginEmail"].ToString();

        private static string Senha = ConfigurationManager.AppSettings["PassEmail"].ToString();

        private static string Url = ConfigurationManager.AppSettings["Url"].ToString() + "/Account/ChangePassword/";

        public static async Task EnviarMensagem(string Para, string Assunto, string Codigo, string Nome, string Token)
        {
            //Template html
            var html = CreateBody(Codigo, Nome, Token);

            try
            {

                MailMessage msg = new MailMessage();
                msg.From = new MailAddress(Login); //Remetente
                msg.To.Add(new MailAddress(Para)); //Destinatario
                msg.Priority = MailPriority.High;
                //msg.Attachments.Add(attachment);
                msg.AlternateViews.Add(html);

                msg.IsBodyHtml = true;
                msg.Subject = Assunto;//Assunto
                //msg.Body = html.ToString();

                SmtpClient smtp = new SmtpClient("smtp-mail.outlook.com", 587);
                smtp.EnableSsl = true;
                smtp.UseDefaultCredentials = false;
                smtp.Credentials = new NetworkCredential(Login,Senha); ;
                smtp.Send(msg);


                // Log de acesso a nova senha
                Log l = new Log
                {
                    Evento = "Lembrar Senha",
                    Mensagem = "Solicitação de nova senha",
                    Pagina = "Lembrar Senha",
                    Cpf = Codigo,
                };

                LoggerRepository log = new LoggerRepository();
                log.Save(l);

            }
            catch (Exception ex)
            {

                Log l = new Log
                {
                    Evento = "Lembrar Senha",
                    Mensagem = ex.Message,
                    Pagina = "Lembrar Senha",
                    Cpf = Codigo,
                };

                LoggerRepository log = new LoggerRepository();
                log.Save(l);

                throw ex;
            }

        }

        // Cria o corpo do E-mail
        public static AlternateView CreateBody(string Codigo, string Nome, string Token)
        {
            string template = "";

            //Lê o template
            using (var reader = new StreamReader(HostingEnvironment.MapPath("~/App_Data/Template/RememberPassword.txt")))
            {
                template = reader.ReadToEnd();
            }

            string imagem = HttpContext.Current.Server.MapPath("~/Content/logo_sabesprev.PNG");

            LinkedResource attachment = new LinkedResource(imagem);
            attachment.ContentId = "EmbeddedLogo";
            attachment.ContentType.MediaType = MediaTypeNames.Image.Jpeg;
            attachment.ContentLink = new Uri("cid:" + attachment.ContentId);



            //Seta os parametros no template do E-mail
            template = template.Replace("{Nome}", Nome);
            template = template.Replace("{Url}", Url);
            template = template.Replace("{Codigo}", Codigo);
            template = template.Replace("{Token}", Token);

            AlternateView htmlView = AlternateView.CreateAlternateViewFromString(template, null, MediaTypeNames.Text.Html);
            htmlView.LinkedResources.Add(attachment);

            return htmlView;

        }
    }
    
asked by anonymous 25.07.2018 / 21:30

0 answers