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?
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.
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.
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">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With