0

我从 Libraray/Preferences/com.apple.mail.plist 获取用户邮件地址。Lion 中不再存在它们:P 我必须使用脚本桥吗?有什么提示吗?谢谢

4

3 回答 3

4

我会把它们从地址簿中取出。无论使用什么电子邮件应用程序,这都应该有效。

// Find 'me' card in address book.
ABPerson* meCard = [[ABAddressBook sharedAddressBook] me];
if( meCard == nil ) {
    NSLog( @"Could not find me!" );
    return;
}

// Get my email addresses.
ABMultiValue* anEmailList = [meCard valueForProperty:kABEmailProperty];
if( anEmailList == nil ) {
    NSLog( @"I have no email!" );
    return;
}

// Output them.
for( NSUInteger index = 0; index < [anEmailList count]; index++ ) {
    NSString* aLabel = [anEmailList labelAtIndex:index];
    NSString* aValue = [anEmailList valueAtIndex:index];
    NSLog( @"%@: %@", aLabel, aValue );
}
于 2011-07-22T21:47:12.127 回答
2

Lion 中的 Mail 将等价物存储在~/Library/Mail/V2/MailData/Accounts.plist中。但是请注意,您假设用户使用 Apple Mail 程序,除非这是您真正需要的,否则您可能希望有其他方法来获取地址。例如,您可以根据系统的设置方式使用 CSIdentity API,例如 CSIdentityGetEmailAddress()。

于 2011-07-22T19:57:29.427 回答
0

苹果脚本将完成工作。

于 2011-09-14T05:51:33.747 回答