I’ve struck a real hassle when trying to script Mail app.
When I script to move a message from one folder to another, mail is very slow at actually shifting them, and a ‘ghost’ of the message is seen by the script. Sometimes I’ve had a dozen messages show up in the script, (but not in the actual mail message folder), where there is actually only one. Even when the is no mail showing in the folder, the script might see several.
This can be persistent across restarts of Mail. I’m using the included line to get the messages.
Does anyone know of a way of getting Mail to update it’s folders please?
set TemporaryMail to messages of mailbox MailBoxName
The only suggestion I would have is to get messages for the folder/box once and then move them. If you are doing this repeatedly, then put in a delay between repetitions so that Mail has time to move the previous messages before re-checking the folder/box.
Thanks, but the problem is more complex than that.
I’ve actually got a folder action script attached to the ‘messages’ folder inside the mail folder. This script activates when a mail rule diverts messages to the box. The ‘on adding items’ script might trigger the activation twice or more quite quickly, or some time apart, but the problem still persists, even across restarts of Mail.
What I’ve just started trying is to check the box twice in a row, and load the variable containing the mail on the second read. Seems to be working OK for now, but I’m keeping my fingers crossed.
So let me understand - you’re using both mail rules AND Finder folder actions on the actual message files?
the rule shifts only those messages that match the address book, and the folder action then processes them, saving a cover sheet that explains the details of the message as rtf file, then automatically prints any attachment files that are picture files or doc or excel files.
If there’s a problem printing, the attachments can be removed and re-dropped onto the mail folder to be re-processed. The main thing is to get as much printed automatically as possible, and manually deal with those that don’t.
As well, the folder allows new clients to be added to the address book, and then their mail is simply dropped on the mail folder for processing.