How to retreive the Phone Number and the Email Address from Windows Phone 7 Contacts in c#

The PhoneNumberChooserTask and the EmailAddressChooserTask in the Windows Phone 7 API helps the user to select the PhoneNumber and the Email Address of the selected contact .

When this chooser is used , the Contacts page is opened for the user to select the Name . The Phone Number and the Email Address are retreived if it has one from the selected contacts based on the Chooser used .

To retreive the phone number , all that one should do is to create a new instance of the PhoneNumberChooserTask , attach an phoneNumberChooserTask_Completed Event handler and call the Show method .

PhoneNumberChooserTask PhoneNrChooserTask = new PhoneNumberChooserTask();

PhoneNrChooserTask.Completed += new EventHandler<PhoneNumberResult>(phoneNumberChooserTask_Completed);

PhoneNrChooserTask.Show();

void phoneNumberChooserTask_Completed(object sender, PhoneNumberResult e)
{

  if (e.TaskResult == TaskResult.OK)
  {
      MessageBox.Show(e.PhoneNumber.ToString);
  }

}

The same applies to the EmailAddressChooserTask too .

EmailAddressChooserTask selectEamilAddress = new EmailAddressChooserTask();

selectEamilAddress.Completed += new EventHandler<EmailResult>(emailAddressChooserTask_Completed);

selectEamilAddress.Show();

void emailAddressChooserTask_Completed(object sender, EmailResult e)
{

  if (e.TaskResult == TaskResult.OK)
  {
      MessageBox.Show(e.Email);
  }
}
If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

No Responses

  1. How to retreive the Phone Number and the Email Address from Windows Phone 7 Contacts in c | ProgramInDotnet August 1, 2011 Reply

Leave a Reply


x

Interesting BlogPosts to read

Event on Building intelligent bots with the Microsoft Bot Framework in Manchester
Want to learn about building intelligent bots using Microsoft's Bot Framework. Here's an interesting...
Barracuda Introduces Email Threat Scan for Microsoft Office 365
With the number of advanced threats on the rise and affecting companies of all sizes, Barracuda toda...
Microsoft Showcases the Power of Analytics and Machine Learning to Transform Businesses and Drive Inclusive Growth
Microsoft India today inaugurated the first edition of Machine Learning & Data Sciences (ML&...