0

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:example@gmail.com?subject=enquiry &body=+ "email"";
}
Ivan Wooll
  • 4,145
  • 3
  • 23
  • 34
Çløüd
  • 1
  • 1
  • 1
    Does this answer your question? [mailto using javascript](https://stackoverflow.com/questions/10172499/mailto-using-javascript) – Dominik Nov 20 '22 at 00:10

1 Answers1

2

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

getElemenById should be getElementById (add the 't')

"mailto:example@gmail.com?subject=enquiry &body=+ "email"" should be

"mailto:example@gmail.com?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:example@gmail.com?subject=enquiry&body=" + email;
}
MrDiamond
  • 958
  • 3
  • 17