Invoke / click a mailto link with JQuery / JavaScript

Solution 1:

You can use window.location.href here, like this:

window.location.href = "mailto:[email protected]";

Solution 2:

You can avoid the blank page issue discussed above by instead using .click() with a link on the page:

document.getElementById('mymailto').click();
...
<a href="mailto:...." id="mymailto" style="display:none"></a>

Solution 3:

the working answer for me, tested in chrome, IE and firefox together with outlook was this

window.location.href = 'mailto:[email protected]?subject=Hello there&body=This is the body';

%0d%0a is the new line symbol of the email body in a mailto link

%20 is the space symbol that should be used, but it worked for me as well with normal space