告诉Mail.app使用MacRuby检查新邮件

告诉Mail.app使用MacRuby检查新邮件,ruby,applescript,macruby,Ruby,Applescript,Macruby,我想使用MacRuby告诉Mail.app检查新电子邮件。但是,在使用SBApplication获得应用程序引用后,我不知道如何进行此操作 我有以下简单的脚本: #!/usr/local/bin/macruby framework 'ScriptingBridge' mail = SBApplication.applicationWithBundleIdentifier("com.apple.mail") # mail.check_for_new_mail? 基本上,我想在MacRuby中执

我想使用MacRuby告诉Mail.app检查新电子邮件。但是,在使用SBApplication获得应用程序引用后,我不知道如何进行此操作

我有以下简单的脚本:

#!/usr/local/bin/macruby
framework 'ScriptingBridge'

mail = SBApplication.applicationWithBundleIdentifier("com.apple.mail")
# mail.check_for_new_mail?
基本上,我想在MacRuby中执行以下AppleScript:

tell application "Mail"
    check for new mail
end tell
是的,我可以用AppleScript。但我更喜欢Ruby。

#!/usr/local/bin/macruby
framework 'ScriptingBridge'

mail = SBApplication.applicationWithBundleIdentifier("com.apple.mail")
mail.accounts.each {|account| mail.checkForNewMailFor(account) }
提示:使用
put(mail.methods(true,true)-Object.new.methods)
返回对象和祖先可用的cocoa-only方法列表


提示:使用
put(mail.methods(true,true)-Object.new.methods)
返回对象和祖先可用的cocoa-only方法列表

mail.accounts.map
?这不应该是
mail.accounts.each
?@Sean:获取Cocoa-only方法的好技巧。干杯<代码>邮件.帐户.地图?这不应该是
mail.accounts.each
?@Sean:获取Cocoa-only方法的好技巧。干杯