Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

How to retrieve the Phone Number and the Email Address from WP7 Contacts in C#

DZone's Guide to

How to retrieve the Phone Number and the Email Address from WP7 Contacts in C#

·
Free Resource

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

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

To retrieve 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 to.

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);
  }
}




Topics:

Published at DZone with permission of Senthil Kumar, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}