Over a million developers have joined DZone.

Windows 8 Metro app: Sending an Email. (Compared to Windows Phone 7’s EmailComposeTask)

DZone's Guide to

Windows 8 Metro app: Sending an Email. (Compared to Windows Phone 7’s EmailComposeTask)

· Mobile Zone
Free Resource

Discover how to focus on operators for Reactive Programming and how they are essential to react to data in your application.  Brought to you in partnership with Wakanda


In a Windows Phone 7 app, sending an email requires an instance of EmailComposeTask. EmailComposeTask is really easy to use and self-explanatory:

EmailComposeTask emailComposeTask = new EmailComposeTask();

emailComposeTask.Subject = "message subject";
emailComposeTask.Body = "message body";
emailComposeTask.To = "recipient@example.com";

In Windows 8 Metro app, there’s no EmailComposeTask. Instead, you create a “mailto” –uri and launch it:

var mailto = new Uri("mailto:recipient@example.com");
await Windows.System.Launcher.LaunchUriAsync(mailto);

But when compared to an EmailComposeTask, this only fills the “To” –part, but what about the “Subject” and “Body”? Well, the mailto-syntax allows you to define these as query parameters. For example, here’s an example of defining the “subject”, “body” and “to” –fields from code. The uri is automatically escaped by the platform:

var mailto = new Uri("mailto:?to=recipient@example.com&subject=The subject of an email&body=Hello from a Windows 8 Metro app.");
await Windows.System.Launcher.LaunchUriAsync(mailto);


With this knowledge, it would be rather easy to build a custom EmailComposeTask for Windows 8.

Learn how divergent branches can appear in your repository and how to better understand why they are called “branches".  Brought to you in partnership with Wakanda


Opinions expressed by DZone contributors are their own.


Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}