Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

148
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!