In this post I will show you how to compose and sent an email from you Windows Phone 8.1 app. If you are developing a Windows Phone 8 Silverlight application then you could refer to our other post.
Launchers and choosers – Email Tasks in Windows phone app
The APIs have changed for WinRT applications. Here’s the code that can be used to send email using a Windows Phone 8.1 WinRT application.
// Define Recipient
EmailRecipient sendTo = new EmailRecipient()
{
Address = "maskaravivek@gmail.com"
};
// Create email object
EmailMessage mail = new EmailMessage();
mail.Subject = "Hello world";
mail.Body = "Email Body";
mail.To.Add(sendTo);
// Open the share contract with Mail only:
await EmailManager.ShowComposeNewEmailAsync(mail);
We are using an EmailRecipient
object that contains the email address of the person to whom we wish to send an email. Then we create an object of EmailMessage
class and set its Subject
and Body
. Also we add the all the recipients to the To
list. Finally we call ShowComposeNewEmailAsync
asyncronously to launch the email app.
Recent Comments