The problem I want to solve: Get all the contacts info like name and Mobile phone and write it into file and save in ISO.
- How to use SearchAsync if I want to search available contacts in the phone?
- How to iterate the return-results and write to file one by one of the contact into a file?
这里,我有:
private void btnSearch_Click(object sender, RoutedEventArgs e)
{
Contacts contacts = new Contacts();
contacts.SearchCompleted += new EventHandler<ContactsSearchEventArgs>(contacts_SearchCompleted);
contacts.SearchAsync(displayName,FilterKind.DisplayName,null);
//search for all contacts
contacts.SearchAsync(string.Empty, FilterKind.None, null);
}
<>Update:
如果电话公司是雇佣公司,则以下代码将产生NllException错误。 为什么?
如何获得除<条码>外的所有传真号码。
Same question for Email Addresses
利用这一途径在电话中搜寻所有联系人:
contacts.SearchAsync(searchterm, FilterKind.None, null);
void contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
{
int intTTL = e.Results.Count();
if (intTTL != 0)
{
MessageBox.Show(intTTL.ToString());
foreach (var result in e.Results)
{
string strTTL;
string strName = result.DisplayName;
string MobileNo = result.PhoneNumbers.FirstOrDefault().ToString();
strTTL = strName + "," + MobileNo;
MessageBox.Show(strTTL);
}
else
{
MessageBox.Show("You have not entered any contact info at all.");
}
}