3
votes

I'm trying to create a windows store app that will launch the default mail app (WinJS 8.1). I haven't touched this for a while, but it was working correctly before 8 - 8.1 upgrade. The code looks like this:

var interval = setInterval(function () {
    clearInterval(interval);
    var formattedBodyText = bodyText.replace(/\n/g, '%0d');
    var mailTask = Email.SendNewMail.sendEmail(emailAddress, subject, formattedBodyText);    
}, 500);

And the sendEmail function:

sendEmail: function sendEmail(addess, subject, body) {
    var mailto = new Windows.Foundation.Uri("mailto:?to=" + addess + "&subject=" + subject + "&body=" + body);
    return Windows.System.Launcher.launchUriAsync(mailto);
}

Oddly, this seems to launch Chrome (I assume because that's my default browser). How can I get it to launch the mail app? Has this changed since the 8.1 upgrade?

EDIT:

It looks like the default program for opening mails was changed to Chrome. So, I suppose my question is now: is it possible to FORCE the mail app to open, rather than whatever is associated with the mailto: url? I noticed there was an ms-mail uri - would that be safer to use?

1
I don't know of any way to force a particular app to open. You could mess around with sharing, but I don't know of a way to target mail apps with a share event without other apps picking it up (the targets respond depending on the type of data you share). - Jordan Kasper
What about detecting the default associated program? - Paul Michaels

1 Answers

0
votes

You can't determine which is default mail app in Windows Store app. Moreover there's no way to open Mail app forcefully in Windows Store app. It doesn't make sense. Some user (Like me!) might not like default mail app. So I would recommend to stick to share charm for sending emails.