如何使用Applescript关闭打开的电子邮件

时间:2015-01-21 18:05:18

标签: applescript

我已经能够在Mac OS X 10.10.1上使用以下脚本取得95%的成功但是,我无法收到我打开的“关闭”电子邮件。任何建议???

这是Applescript:

using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
    tell application "Mail"

        -- walk through all matching messages
        repeat with thisMessage in theMessages
            -- open the message
            set openedMail to open thisMessage

            -- perform your UI scripting
            tell application "System Events"
                tell process "Mail"
                    -- Select the Print menu item
                    click (first menu item of menu "File" of menu bar 1 whose name begins with "Print")
                    tell window 1
                        -- Wait until the print sheet appears
                        repeat 30 times
                            if sheet 1 exists then exit repeat
                            delay 0.5
                        end repeat
                        tell sheet 1
                            -- Click the PDF button
                            click menu button "PDF"
                            -- Select the PDF to SBS Dropbox menu item
                            delay 0.5
                            click (first menu item of menu 1 of menu button "PDF" whose name begins with "PDF to SBS Dropbox")
                            delay 4
                        end tell
                    end tell
                end tell
            end tell

            -- close the message
            close openedMail

        end repeat
    end tell
end perform mail action with messages

结束使用

中的条款

1 个答案:

答案 0 :(得分:1)

如果您的代码不起作用,那么为什么不尝试使用之前用于系统事件的相同技术...

click (first menu item of menu "File" of menu bar 1 whose name begins with "Close")

或者您可以告诉邮件使用...

close window 1