Below is a script I've been using within a Hazel rule for a few years. It's purpose is to give me the option of keeping or discarding an e-mail I've just sent. It worked beautifully with a POP account. I've recently switched to using IMAP for the same account, and since then the script hasn't worked.
The Hazel rule (applied to the folder ~/Library/Mail/IMAP-accountname@servername/Sent.imapbox/Messages):
• any file
• date added is in the last 1 minute
• Run Applescript ...
The script:
- Code: Select all
on hazelProcessFile(infile)
tell application "Mail"
activate
set theMessage to message 1 of mailbox "Sent" of account "Mail.com" of application "Mail"
set theSubject to subject of theMessage
display dialog theSubject & "... Save copy?" buttons {"No", "Yes"} default button 1
if (button returned of the result) = "No" then
set mailbox of theMessage to mailbox "Trash" of account "Mail.com" of application "Mail"
end if
set selected mailboxes of front message viewer to {sent mailbox}
set selected mailboxes of front message viewer to {trash mailbox}
set selected mailboxes of front message viewer to {inbox}
display dialog "Continue with Mail?" buttons {"No", "Yes"} default button 1
if (button returned of the result) = "No" then
close front window
end if
end tell
end hazelProcessFile
Should I be using some different terms for IMAP? Or should I set a time delay somewhere? Or is there something else to try? Any help appreciated. (NB: I'm not much of geek with scripting etc, so please minimise the geekspeak in replying ... )
Thanks.