【问题标题】:Prevent Email From Being Sent via Applescript防止通过 Applescript 发送电子邮件
【发布时间】:2013-02-28 04:56:06
【问题描述】:

我有以下 AppleScript(如下)。我正在尝试确认电子邮件的发送。这个 AppleScript 已经成功连接到 Mail.app 中的“发件箱规则”(使用 Mail Act-On),并且我已经验证它在它应该运行的时候(在发送时)运行。

最终目标是向用户弹出一个对话框,询问他们是否“真的”想要发送电子邮件。如果没有,请停止发送电子邮件。

当前脚本尝试删除该消息,但这不起作用。有什么想法吗?

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

        repeat with thisMessage in messageList

            set theResult to display dialog "Send?" buttons {"OK", "Cancel"} default button 2
            if button returned of theResult is not equal to "OK" then
                delete thisMessage
            end if

        end repeat
    end perform mail action with messages
end using terms from

【问题讨论】:

    标签: macos email applescript


    【解决方案1】:

    我认为display dialog 中的“取消”按钮将立即结束脚本的执行,这意味着delete thisMessage 行永远不会运行。

    您可以尝试将其更改为:

    set theResult to display dialog "Send?" buttons {"OK", "No, Delete Message"} default button 2
    if button returned of theResult is not equal to "OK" then
    ...
    

    【讨论】:

      猜你喜欢
      • 2014-07-01
      • 2012-03-10
      • 1970-01-01
      • 1970-01-01
      • 2014-03-27
      • 1970-01-01
      • 2012-01-07
      • 2012-04-27
      相关资源
      最近更新 更多