EziData Solutions

Web, NET and SQL Server

Send email to a contact from your WP7 App

In a previous post I showed you how easy it is to send an email from within your Windows Phone application. In that post I focussed on the EmailComposeTask, that is used to launch the native email application and prepopulate fields such as the To address, subject and body.

When I built the DVDLibrary app I decided to include the ability to email directly from the app, specifically so that users could inform their fiends about movies they had, or wanted to get. In this scenario it made sense to use the EmailAddressChooserTask before calling the EmailComposeTask, so that the user could select one of their contacts to send the email to.

private void Button_Click(object sender, RoutedEventArgs e)

{

    EmailAddressChooserTask email = new EmailAddressChooserTask();

    email.Completed += new EventHandler<EmailResult>(email_Completed);

    email.Show();

}

 

void email_Completed(object sender, EmailResult e)

{

    //only continue if the user selected a contact

    if (e.TaskResult == TaskResult.OK)

    {

        //you could also use values from you app

        //such as the product or business selected

        EmailComposeTask em = new EmailComposeTask();

        em.To = e.Email;

        em.Subject = "This is a great movie";

        em.Body = "Check out this great movie...";

    }

}

Posted: Feb 24 2011, 06:26 by CameronM | Comments (0) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: WP7