Search code examples
javascriptemailmailto

Email body is always empty


I have the following formatEmail function:

function formatEmail(attachment, body) {
    body = "test";
    window.location.href = "mailto:" + emailTo + "?subject=" + self.subject() + "&body=" + body;
}

That opens an email on the client machine, the email opens but the body is always empty.

Any idea what can causes that?


Solution

  • Thank God my answer below fixes your issue :)

    Just always remember to prevent empty values in the query to avoid misparsing. If the subject value is empty or with invalid characters the next parameter will be misparsed. :)