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

Sending an Email from Windows Phone

To help get feedback, complaints and problems from users of our Windows Phone apps on the Marketplace we have started to include an ‘email us’ link. This link uses the email launcher task called EmailComposeTask to fill in the recipient (our email), and the Subject (our application name). 

The EmailComposeTask launches the email application on the OS, which prompts the user to select the account they want to use, for instance Live or Outlook. Once they select the account, they new email message is displayed and they have the option to edit the subject line, message body or even cancel sending the email altogether.

private void Button_Click(object sender, RoutedEventArgs e)

{

    EmailComposeTask emailComposeTask = new EmailComposeTask();

    emailComposeTask.To = "sales@GreatApp.com";

    emailComposeTask.Body = "I love this application";

    emailComposeTask.Subject = "Great App";

    emailComposeTask.Show();

}

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