How to use the email compose task for Windows Phone 8
Applies to: Windows Phone 8 and Windows Phone Silverlight 8.1 | Windows Phone OS 7.1
Use the email compose task to enable users to send email from your application. The task launches the email application and displays a new email message with the cursor in the To field and the software keyboard displayed. You can optionally specify recipients, a message subject, and a message body, which are prepopulated in the new message. You can also specify a code page for the new message. The message is sent only when the user presses the send button.
By using Launchers, you help provide a consistent user experience throughout the Windows Phone platform. For more information, see Launchers and Choosers for Windows Phone 8.
On Windows Phone Emulator, an exception occurs when using the email compose task. Test the email compose task on a physical device.
To use the email compose task
Add the following statement to your code.
Add the following code to your application wherever you need it, such as in a button click event. To test this procedure, you can put the code in the page constructor. This is the code to launch the task.
EmailComposeTask emailComposeTask = new EmailComposeTask(); emailComposeTask.Subject = "message subject"; emailComposeTask.Body = "message body"; emailComposeTask.To = "firstname.lastname@example.org"; emailComposeTask.Cc = "email@example.com"; emailComposeTask.Bcc = "firstname.lastname@example.org"; emailComposeTask.Show();
If an email account is not set up on the phone, the application prompts the user to set up an account.