According to Sending emails with Javascript, one way to do it is the following:
function sendMail() {
var link = "mailto:[email protected]"
+ "[email protected]"
+ "&subject=" + encodeURIComponent("This is my subject")
+ "&body=" + encodeURIComponent(document.getElementById('myText').value)
;
window.location.href = link;
}
However I'm trying to personalize it, sending emails with variables. I did this:
function sendMail(subject="test", body, mail="[email protected]") {
var link = `mailto:${mail}`
+ "&subject=" + encodeURIComponent(`${subject}`)
+ "&body=" + encodeURIComponent(`${body}`)
;
window.location.href = link;
But, when sending the email, I achieve this fail:

It seems like it is not recognizing each variable. How to solve it?
?, which separates the URL from the query string. Also, a better way to construct a full URL with query string is to use thenew URL()objectmailto:can use. I don't have one andmailto:links just don't work for me. If you want to be able to send email from a form pass the message to your server and have that send the message.