0

So I have function like this which is called on button click:

function sendEmail() {
    var subject = 'test subject';
    var href = window.location.origin + window.location.pathname;
    var body = 'test body: ' + href;

    window.location.href = 'mailto:?subject=' + subject + '&body=' + body;
}

Is it possible to save this href in email body as a real link not as a string ??

Thanks for any suggestions.

Albert Einstein
  • 7,472
  • 8
  • 36
  • 71
SimpleCoder
  • 33
  • 1
  • 8
  • It's not possible. See similar question here https://stackoverflow.com/questions/5620324/mailto-link-with-html-body – Sergey Mell Nov 29 '18 at 08:29
  • Possible duplicate of [mailto link with HTML body](https://stackoverflow.com/questions/5620324/mailto-link-with-html-body) – jonrsharpe Nov 29 '18 at 08:30
  • Instead of using window.location.href you can either use submit form or Ajax call so you can transfer any data of any type. – DHARMENDRA SINGH Nov 29 '18 at 08:59

2 Answers2

0

No, it's impossible to implement like this because body should be plain text here.

Volod
  • 1,283
  • 2
  • 15
  • 34
0

You need to setup your mail function to send Content-Headers for TEXT/HTML instead of TEXT/PLAIN.

If so you can use simple html to send the mail. That would make the link look like:

function sendEmail() {
    var subject = 'test subject';
    var href = window.location.origin + window.location.pathname;
    var body = 'test body: <a href="' + href + '">Any Description</a>';
}

If your solution would work it would be possible to force people to redirect to another page by reading their mails and for sure this should not be the case.

Sandro Schaurer
  • 416
  • 4
  • 13