In this post we will review how to open the default mail client on an end user machine using javascript from a site. We want the email to be created in a new window, so the current site does not disappear after sending the email. This is just a small effort, but so unclear, that it worth mentioning.
const encodedSubject = encodeURIComponent('My Subject')
const encodedBody = encodeURIComponent(`The email body.
New
lines
can
be
included
here
`)
const link = `mailto:you@company.com?subject=${encodedSubject}&body=${encodedBody}`
window.open(text, '_blank')
No comments:
Post a Comment