prevent电子邮件发件人通过AppleScript的发送 [英] Prevent Email From Being Sent via Applescript
问题描述
我已经得到了以下的AppleScript(如下图)。我试图确认电子邮件的发送。这AppleScript的是已经成功地迷上了一个发件箱规则,在Mail.app(使用邮件法案 - ),并且我已经验证它运行时,它应该(在发送时)。
的最终目标是一个对话框弹出给用户,询问他们是否真的要发送的电子邮件。如果没有,停止发送的电子邮件。
目前的脚本尝试删除该消息,但不起作用。任何想法?
使用从申请邮件条款
与邮件给messageManager的规则theRule进行邮件操作 与thisMessage重复给messageManager 设置theResult显示对话框发送?按钮{OK,取消}默认按钮2
如果theResult的返回按钮不等于确定,然后
删除thisMessage
万一 重复结束
最终执行与邮件的邮件操作
结束使用条款从
我认为,在显示对话框中的取消按钮
将立即停止脚本的执行哪些意味着删除thisMessage
行从未运行。
您可以尝试改变,要类似:
设置theResult显示对话框发送?按钮{OK,不,删除消息}默认按钮2
如果theResult的返回按钮不等于确定,然后
...
I've got the following AppleScript (below). I'm attempting to confirm the sending of an email. This AppleScript is already successfully hooked up to an "outbox rule" (using Mail Act-On) in Mail.app, and I've verified that it runs when it is supposed to (at the time of sending).
The ultimate goal is to pop a dialog to the user, asking if they "really" want to send the email. If not, stop the email from being sent.
The current script attempts to delete the message, but that doesn't work. Any ideas?
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
I think that a "Cancel" button in a display dialog
will immediately end execution of your script which means that the delete thisMessage
line never is run.
You might try changing that to something like:
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
...
这篇关于prevent电子邮件发件人通过AppleScript的发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!