Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

153
Visualizações
send html page in mail content by jquery

I have a nice long html web design. My goal is to send an e-mail by clicking the button at the bottom of this page.

First of all, I assign all the html code of the web page open on the javascript side to a variable.

var pageContent = $("body").html();

I'm sending this variable to the web service running in my local

$.getJSON("MailSend?mail_adres=example@gmail.com&content=" + pageContent + "", function (datas) 
{
  console.log(datas);
});

On the asp.net mvc side, the back-end code of this json web service is as follows;

        public JsonResult MailSend(string mail_adres,string content)
        {
            if (ModelState.IsValid)
            {
                MailMessage mail = new MailMessage();
                mail.To.Add(mail_adres);
                mail.From = new MailAddress("example@mydomain.com");
                mail.Subject = "Try mail";
                string Body = content.ToString();
                mail.Body = Body;
                mail.IsBodyHtml = true;
                SmtpClient smtp = new SmtpClient();
                smtp.Host = "smtp.mydomain.com";
                smtp.Port = 587;
                smtp.UseDefaultCredentials = false;
                smtp.Credentials = new System.Net.NetworkCredential("example@mydomain.com", "mypassword"); 
                smtp.EnableSsl = false;
                smtp.Send(mail);
                return Json("ok",JsonRequestBehavior.AllowGet);
            }
            else
            {
                return Json("no", JsonRequestBehavior.AllowGet);
            }
        }

Potentially malicious code has been detected on the client, but this is normal. There are special and different characters such as < > in html codes

Full error text: System.Web.HttpRequestValidationException: A potentially harmful value Request.QueryString was detected on the client.

Screenshot of trying to send html code directly without the selected e-mail address;

enter image description here

What should I do for this?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda