开发者

Can we access the emailids from the contactlist from iPhone?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜