【问题标题】:AppleScript aborts execution after moving a mail message?AppleScript 在移动邮件消息后中止执行?
【发布时间】:2012-02-17 20:58:49
【问题描述】:

我正在使用带有 Mail.app 规则的以下脚本。

似乎在我的计算机上,将邮件移动到垃圾箱后,代码没有被执行。 (下面的 adayzdone 报告它对他有用)。

我怎样才能找出这个问题的原因并解决它?

using terms from application "Mail"
    on perform mail action with messages theMessages
        repeat with eachMessage in theMessages
            set theText to content of eachMessage

            --
            -- ... here happens some processing
            --

            -- this works:
            move eachMessage to mailbox "Trash"

            -- but this doesn't:
            display dialog "reached this point"

            -- i.e. additional code I'm adding here isn't executed...
        end repeat
    end perform mail action with messages
end using terms from

【问题讨论】:

  • 讨论了一个相关的探测问题over here。您是否碰巧在 Mail.app 中配置了多个帐户?
  • 尝试将move eachMessage... 行包装在try...on error 块中。您可以使用do shell script "logger -t 'Your script name' " & whateverTextYouLike 将错误消息记录到控制台。

标签: applescript


【解决方案1】:

使用 Mail 中的规则调用它,这个脚本对我有用。您确定邮件已到达收件箱,并且没有被 gmail 的“跳过收件箱”等过滤器捕获吗?

using terms from application "Mail"
on perform mail action with messages theMessages
    repeat with eachMessage in theMessages
        set theText to content of eachMessage
        move eachMessage to mailbox "Trash"
        display dialog "reached this point"
        beep 2
    end repeat
end perform mail action with messages
end using terms from

【讨论】:

  • 是的,我确定。处理部分是成功的,我可以看到由于这条规则,邮件从收件箱移到了垃圾箱。但对话框仍然没有显示给我..
  • 顺便说一句,如果我在“移动到垃圾箱”之前添加一个“显示对话框”,该对话框确实会显示出来。
  • 在我的电脑上,我得到了对话框和 beep2。不知道发生了什么。
猜你喜欢
  • 2015-06-05
  • 1970-01-01
  • 2012-12-03
  • 2020-11-05
  • 1970-01-01
  • 2023-04-03
  • 1970-01-01
  • 2012-08-23
相关资源
最近更新 更多