开发者

How do I get all the mail accounts set up in Mail.app programmatically?

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜