Can we access all the email IDs for each contact from the iPhone contactlist through code?
You will get the individual email ids by given code...
ABAddressBookRef addressBook = ABAddressBookCreate();
CFArrayRef people = ABAddressBookCopyArrayOfAllPeople(addressBook);
NSString *contactName = lblTitle.text;
for(int i = 0;i<ABAddressBookGetPersonCount(addressBook);i++)
{
ABRecordRef person = CFArrayGetValueAtIndex(people, i);
NSString *strEmail = [arContactData valueForKey:@"Email"];
NSMutableArray *arEmailList = [[NSMutableArray alloc] init];
ABMultiValueRef emails = ABRecordCopyValue(person, kABPersonEmailProperty);
for(CFIndex idx = 0; idx < ABMultiValueGetCount(emails); idx++)
{
CFStringRef emailRef = ABMultiValueCopyValueAtIndex(emails, idx);
NSString *strLbl = (NSString*)ABAddressBookCopyLocalizedLabel (ABMultiValueCopyLabelAtIndex (emails, idx));
NSDictionary *dicTemp = [[NSDictionary alloc]initWithObjectsAndKeys:strEmail,@"value", strLbl,@"label", nil];
[arEmailList addObject:dicTemp];
}
}
Sure, use the ABAdressBook class:
ABAddressBookRef addressBook = ABAddressBookCreate(); NSArray *allPeople = (NSArray *)ABAddressBookCopyArrayOfAllPeople(addressBook);
Now you have all contacts in the allPeople array, then just get the email by key.