How to use the email compose task for Windows Phone 8
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
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.
Dim emailComposeTask as EmailComposeTask= new EmailComposeTask() emailComposeTask.Subject = "message subject" emailComposeTask.Body = "message body" emailComposeTask.To = "email@example.com" emailComposeTask.Cc = "firstname.lastname@example.org" emailComposeTask.Bcc = "email@example.com" emailComposeTask.Show()
If an email account is not set up on the phone, the application prompts the user to set up an account.