1

I would like to create an HTML email using JavaScript so that the draft is ready, and the user can send the email.

Here is what I have tried so far:

location.href = "mailto:"+"isflibrary.net.com.de.xxx"+'?cc='+"emailCC"+'&subject='+("Stuff bought by: ", email)+'&body='+"<a href="https://www.mywebsite.com">Visit mywebsite.com!</a>";

Wrong output: wrong output

Output that I want: enter image description here

randomUser786
  • 1,527
  • 3
  • 13
  • 25
  • In case the OP provides the example as executable snippet one (the OP too) immediately could see whether and/or where the approach does fail. – Peter Seliger Sep 05 '21 at 08:59
  • even if `email` was declared `... + ("Stuff bought by: " , email ) + ...` obviously features a wrong syntax. Within the concatenation there can not be all of a sudden two comma separated values – Peter Seliger Sep 05 '21 at 09:11

1 Answers1

1

Is this what you were trying to do?

$(document).ready(function() {
  $('#btn').click(function() {
    mailto = 'isflibrary.net.com.de.xxx';
    emailCC = 'test@emailCC.com';
    subject = 'Stuff bought by: ' + mailto;
    htmlBody = '<a href="https://www.mywebsite.com">Visit mywebsite.com!</a>';
    location.href = "mailto:" + mailto + "?cc=" + emailCC + "&subject=" + subject + "&body=" + htmlBody;
  });
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button id=btn>e-mail</button>
Baro
  • 5,300
  • 2
  • 17
  • 39
  • Thanks for your reply, but the body still appears as HTML code. – randomUser786 Sep 05 '21 at 09:17
  • Ok, I thought it was a syntax problem, so I have bad news. It can't be done: [SO Answer](https://stackoverflow.com/questions/5620324/mailto-link-with-html-body) – Baro Sep 05 '21 at 09:25