Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

154
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda