How to use mailto function in JavaScript

How do I use the "mailto" function in JavaScript for a table containing product details

function SendEmail() {
  var email = document.getElemenById("list").value;
  window.location.href = "mailto:[email protected]?subject=enquiry &body=+ "email"";
}

Upvotes: 0

Views: 1272

Answers (1)

MrDiamond
MrDiamond

Reputation: 1092

What you are doing in your function is correct, but it has errors.

getElemenById should be getElementById (add the 't')

"mailto:[email protected]?subject=enquiry &body=+ "email"" should be

"mailto:[email protected]?subject=enquirt&body=" + email (remove space in between "enquirt" and "&body", correctly format end)

Finished function:

function SendEmail() {
  var email = document.getElementById("list").value;
  window.location.href = "mailto:[email protected]?subject=enquiry&body=" + email;
}

Upvotes: 3

Related Questions