0

我已经使用 MFmailComposer 实现了发送电子邮件代码...

很好,但问题在于选择收件人的电子邮件地址

我想从通讯录联系人中获取电子邮件地址。

请如何检索此任何帮助

我已经为它提供的联系人实现了一个 ABPeoplePickerNavigationController 委托方法

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker
      shouldContinueAfterSelectingPerson:(ABRecordRef)person
                                property:(ABPropertyID)property
                              identifier:(ABMultiValueIdentifier)identifier 
{
    if (property == kABPersonPhoneProperty) 
    {
        ABMultiValueRef emails = ABRecordCopyValue(person, property);
        CFStringRef phonenumberselected = ABMultiValueCopyValueAtIndex(emails, identifier);
        CFStringRef emailLabelSelected = ABMultiValueCopyLabelAtIndex(emails, identifier);
        CFStringRef emailLabelSelectedLocalized = ABAddressBookCopyLocalizedLabel(ABMultiValueCopyLabelAtIndex(emails, identifier));
        NSLog(@"\n EmailValueSelected = %@ \n EmailLabelSelected = %@ \n \EmailLabeSelectedlLocalized = %@", phonenumberselected, emailLabelSelected, emailLabelSelectedLocalized);

        recipientField.text = (NSString *)emails; //Crashes but accepts 'phonenumberselected'

       NSLog(@" emails###:%@...  phonenumberselected%@...  emailLabelSelected %@.... emailLabelSelectedLocalized %@")

    //emails###: ABMultiValueRef 0x80b7bc0 with 1 value(s) //**Log output Displyas like this**


        [ self dismissModalViewControllerAnimated:YES ];
        return NO;
    }   
    return YES;

}

How to write code to pick the selected EMail address from phone book

4

1 回答 1

1

以下链接用于实现的代码,其中从联系人获取电子邮件地址并添加到我们的数组中,

参考链接

于 2012-04-27T11:28:41.530 回答