I have a web application from which the user can send an email using a mailto link. Basically, I concatenate a string that contains the subject, body and recipients and then the code triggers a mailto, somewhat like this:
var MailToLink = 'mailto:' + TheEmailString;
window.open(MailToLink, '_blank'); //option 1
window.open(MailToLink); //option 2
Initially, I only had option 2 because on my dev machine I have Outlook. But as I started some alpha testing, another user was using Gmail and the mailto link would open in the same window as my app so I changed my code to option 2 so that the email opens in another window. The problem now is that when the user is on Outlook, the link opens both an Outlook message and a new blank window.
Is there a way to detect if the user is using a web-based email client or a local client? I would like to do something like this:
if (IsUsingWebMailClient) {
window.open(MailToLink, '_blank');
} else {
window.open(MailToLink);
}
I'm not sure if this is even possible; how do I detect the mailto client using JavaScript?