Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mailto link not copying body of email on Chromebook

I'm generating a mailto: link that also contains the body of an email. I'm opening the link using JavaScript to launch the mailto: client of the OS. On Chromebooks the link opens Gmail with the email address, but not the body of the email. This is the link:

var MailToLink = 'mailto:[email protected]?subject=Test%20Email%20Subject&body=Great,%20the%20mailto%20protocol%20works%20and%20you%27re%20good%20to%20go.%20Good%20luck.'

This is the line I use to open the link: window.open(MailToLink, '_blank');

It works just fine on Windows 10 OS with Thunderbird and Gmail for Android.

Is there something I need to change for Chromebooks?

like image 513
frenchie Avatar asked Jun 05 '19 17:06

frenchie


2 Answers

What about setting location.href instead of creating a popup?

location.href = "mailto:[email protected]?subject=Test%20Email%20Subject&body=Great,%20the%20mailto%20protocol%20works%20and%20you%27re%20good%20to%20go.%20Good%20luck."

Looking for an answer drawing from credible and/or official sources.

Good to know is that subject and body in mailto links are described in RFC 2368 - The mailto URL scheme

Clients that resolve mailto URLs into mail messages should be able to correctly create RFC 822-compliant mail messages using the "subject" and "body" headers.

Please also note there is a paragraph over "unsafe headers" - so I think the content could be also important.

  1. Unsafe headers

    The user agent interpreting a mailto URL SHOULD choose not to create a message if any of the headers are considered dangerous; it may also choose to create a message with only a subset of the headers given in the URL. Only the Subject, Keywords, and Body headers are believed to be both safe and useful.

like image 187
Julian Avatar answered Sep 28 '22 08:09

Julian


Try this

var MailToLink = 'mailto:[email protected]?subject=Test%20Email%20Subject&body=Great,%20the%20mailto%20protocol%20works%20and%20you%27re%20good%20to%20go.%20Good%20luck.'
var sendEmail = document.getElementById('sendEmail');

  sendEmail.addEventListener('click', function (e){
    window.location.href = MailToLink;
  });
<input type="button" id="sendEmail" value="submit">
like image 39
Fadi Avatar answered Sep 28 '22 07:09

Fadi