Windows Store App – Send Email

Number of Views : 4047

I have just submitted my first app to the Windows app store. I will send the link out once it gets approved. During the development process I had experimented with a lot of options for my applications. I finally decided to use an html / javascript app type. The choices in for the Windows Store Apps are C#/VB, C++, or HTML/Javascript.

In that choice you gain some features and lose some features. In my application I had intended to allow the user to send data to themselves. Basically a copy / paste of contents to send as a reference. I found it was difficult to do this. I was able to create a method that uses the “Mailto” link reference. In discussion forms it sounds like sharing is the proper way to do this. However the html app development had not implemented sharing yet (MSDN) or it is not supported for text or html.

To get around this I used a mailto and launcher option.

// The URI Mailto to launch - I had to htmlencode
var uriMailTo = "mailto:[email protected]?subject=SomeSubject&body=Welcome%20to%20my%application";
// Create a Uri object from a URI string  -
var uri = new Windows.Foundation.Uri(uriMailTo);
// Launch the URI
Windows.System.Launcher.launchUriAsync(uri).then(  
   function (success) {
      if (success) {
         } else {
      }
   });

The uriMailTo variable contains the main information. “mailto:[email protected]?subject=SomeSubject&body=Welcome%20to%20my%application” Notice that we need to use html encoded characters “%20” is a space

The uri is then set to an Windows.Foundation.Uri object

From there we use the Windows.System.Luancher I selected to use the launchUriAsync. You can read more about windows.system.launcher at msdn.

Overall I find this a difficult thing to believe that there is not a great way to send an email. When developing a windows 7 Phone app there was an exposed method to just send an email. I would hope for this in the future. This way you can generate a great HTML message and send app information.

Leave a Reply

Your email address will not be published. Required fields are marked *