My app need to know all开发者_StackOverflow中文版 the accounts set up in Mail.app, then ask the user to select one for a specific use. How can I achieve this?
AppleScript is probably the way to go (check NSAppleScript):
http://www.mactech.com/articles/mactech/Vol.21/21.09/ScriptingMail/index.html
Sample:
NSAppleScript* script= [[NSAppleScript alloc] initWithSource:@"tell application \"Mail\" \nname of every account \nend tell"];
NSDictionary* scriptError = nil;
NSAppleEventDescriptor* descriptor=[script executeAndReturnError:&scriptError];
if(scriptError)
{
NSLog(@"Error: %@",scriptError);
return;
}
NSLog(@"Result: %@",descriptor);
精彩评论