我们可以从 iPhone 访问联系人列表中的电子邮件地址吗?

发布于 2024-11-28 00:20:01 字数 45 浏览 0 评论 0原文

我们可以通过代码访问iPhone联系人列表中每个联系人的所有电子邮件ID吗?

Can we access all the email IDs for each contact from the iPhone contactlist through code?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小…楫夜泊 2024-12-05 00:20:01

您将通过给定代码获得个人电子邮件 ID...

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

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];        
        }
    }
乜一 2024-12-05 00:20:01

当然,使用 ABAdressBook 类:

ABAddressBookRef 地址簿 = ABAddressBookCreate();
NSArray *allPeople = (NSArray *)ABAddressBookCopyArrayOfAllPeople(addressBook);

现在,您在 allPeople 数组中拥有了所有联系人,然后只需通过键获取电子邮件即可。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文