Send email from Windows Phone

Sometimes an app need to send some information via email. To reach this gol a programmer need to write a few lines of code.

First of all, we can create a button and attach the Click event to send email. After that, in this event we call the EmailComposeTask and thats all.

Now we can build our email with the usual parameters (To, Subject, Body) and then we send the email.

EmailComposeTask email = new EmailComposeTask();
if ("<email_address>" != string.Empty)
{
     email.To = "<email_address>";
     email.Subject = "Subject message";
     email.Body = "Body message";
     email.Show();
}
else
{
     MessageBox.Show("Some error occours.", "WARNING", MessageBoxButton.OK);
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s