2010-01-26 68 views
0

我试图使用基于当前所选消息的条件(例如,创建一个文件夹来显示发送当前消息的人的所有消息)在Apple Mail中自动创建智能邮箱。显然,我可以手动进入并创建一个智能邮箱,但由于我经常这样做,我希望能够自动化。使用AppleScript创建智能邮箱?

我无法在“词典”中找到任何对邮件中的智能邮箱的引用。我做了一个互联网搜索,找不到任何示例代码来操纵AppleScript中的智能邮箱,仅在2006年的一次讨论中提到它无法完成的参考文献(底线):http://forums.macosxhints.com/archive/index.php/t-51935.html

我也找到一个脚本来调出创建智能邮箱对话框,但这不是我要找的。

任何人都知道是否有方法在AppleScript中创建/编辑智能邮箱?

谢谢。

回答

1

您必须使用GUI脚本。我使用Python + appscript完成大部分脚本,但这里有一个快速的Applescript片段来创建一个Smart Mailbox。我应该注意到,没有正式的Applescript支持处理智能邮箱是可笑的。

 
tell application "Mail" 
    activate 
end tell

tell application "System Events" tell process "Mail" tell menu bar 1 tell menu bar item "Mailbox" tell menu "Mailbox" click menu item "New Smart Mailbox…" end tell end tell end tell

delay 1 keystroke "t" using shift down keystroke "e" keystroke "s" keystroke "t" keystroke tab keystroke "m" keystroke "o" keystroke "r" keystroke "e" end tell

末告诉