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 te开发者_高级运维rms 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
...
精彩评论