I need to automatically open a user's default email client when they save some content on a page. I need to populate the email subject, to address, and put some content in the email body.
What is the best option to achieve this?
I'm aware of the mailto:
attribute, but the user must click on this and I'm not sure it allows you to specifiy the subject and content?
HTML <a> tag provides you option to specify an email address to send an email. While using <a> tag as an email tag, you will use mailto: email address along with href attribute. Following is the syntax of using mailto instead of using http. This code will generate the following link which you can use to send email.
Change Windows 10 Default Email App To set your favorite email client as the system-wide default, head to Settings > Apps > Default Apps. Then in the right panel under the Email section, you will see it is set to the Mail app. Just click on it and choose the email app you want to use as the default from the list.
Choose Mail > Preferences, then click General. Choose an email app from the ”Default email reader” menu.
Or you can right-click the Start button in your taskbar and select “Settings.” When Settings opens, click “Apps” in the sidebar, and then select “Default Apps.” In Default Apps, click the search bar and type in the name of the email app you'd like to use as your default.
As described by RFC 6068, mailto allows you to specify subject and body, as well as cc fields. For example:
mailto:[email protected]?subject=Subject&body=message%20goes%20here
User doesn't need to click a link if you force it to be opened with JavaScript
window.location.href = "mailto:[email protected]?subject=Subject&body=message%20goes%20here";
Be aware that there is no single, standard way in which browsers/email clients handle mailto links (e.g. subject and body fields may be discarded without a warning). Also there is a risk that popup and ad blockers, anti-virus software etc. may silently block forced opening of mailto links.
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