I’m a new user of Hazel and have only a very very basic grasp of some AS stuff. (And am not a geek generally).
By a lot of muddling I’ve managed to produce some scripts that basically work with Hazel. But in relation to Mail, I need a way of being confident that a script triggered by Hazel (where Hazel is working on a ~/Library/Mail “Messages” folder) will “pick up” the same message that Hazel was working on. Not such a problem if dealing with one message at a time; but I get a bit lost if say several messages are copied to a mailbox at the same time.
Here’s one of my scripts, which I use to delete a message from a user mailbox. My Hazel rule has first copied the message to ~/Documents; then it triggers the script:
on hazelProcessFile(infile) tell application "Mail" set theMessage to message 1 of mailbox "Hold" delete theMessage end tell end hazelProcessFile
The “message 1” reference seems to work solidly if there’s only one message in “Hold”. But I’m nervous if I’ve just moved 4 messages together from INBOX to “Hold”. …
So my question: Can I be confident that the message the applescript will select as “message 1” will be the same one that Hazel has just copied to documents? Or is it possible that I’ve ended up deleting a message that hasn’t been copied yet (and now never will be)?
Hope this makes sense. Enlightenment humbly sought …