+ Contact* pContact = static_cast<Contact*>(pContactEnum->GetCurrent());
+
+ IList* pPhoneNumberList = pContact->GetValuesN(CONTACT_MPROPERTY_ID_PHONE_NUMBERS);
+ if (pPhoneNumberList != null)
+ {
+ IEnumerator* pPhoneEnum = pPhoneNumberList->GetEnumeratorN();
+ while (E_SUCCESS == pPhoneEnum->MoveNext())
+ {
+ PhoneNumber* pPhoneNumber = (PhoneNumber*) pPhoneEnum->GetCurrent();
+ //Check if this is the correct contact
+ if (pPhoneNumber->GetPhoneNumber().Equals(phoneNumber))
+ {
+ //save newly fetched contact info.
+ bContactFound = true;
+ personId = pContact->GetPersonId();
+ break;
+ }
+ }
+ delete pPhoneEnum;
+ pPhoneNumberList->RemoveAll(true);
+ delete pPhoneNumberList;
+ }
+ if(bContactFound == true)
+ {
+ break;
+ }