Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 防止通过Applescript发送电子邮件_Macos_Email_Applescript - Fatal编程技术网

Macos 防止通过Applescript发送电子邮件

Macos 防止通过Applescript发送电子邮件,macos,email,applescript,Macos,Email,Applescript,我有下面的AppleScript(如下)。我正在尝试确认发送电子邮件。此AppleScript已成功连接到Mail.app中的“发件箱规则”(使用Mail Act On),并且我已验证它是否在应该运行时(发送时)运行 最终目标是弹出一个对话框给用户,询问他们是否“真的”想发送电子邮件。如果没有,请停止发送电子邮件 当前脚本试图删除该消息,但不起作用。有什么想法吗 using terms from application "Mail" on perform mail action with

我有下面的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
我认为
显示对话框中的“取消”按钮将立即结束脚本的执行,这意味着
删除此消息
行永远不会运行

您可以尝试将其更改为:

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
...