如何编写代码从电话簿中选择所选的电子邮件地址,以便从我的iphone应用程序发送电子邮件

时间:2012-04-27 11:01:46

标签: iphone objective-c mfmailcomposeviewcontroller abpeoplepickerview

我已使用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

2 个答案:

答案 0 :(得分:2)

请完成此Link

答案 1 :(得分:1)

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

Reference Link