Mail.app - Applescript - Looking for help with my 1st Applescript
*Here's the situation:*
I use Smart Mailboxes a lot. It's my primary window into dealing with email.
I use MailTags (an addon for Mail) to apply keywords to messages, via Mail Act-On rules (an addon by the same company).
I use Smart Mailboxes to show me messages with various keywords etc.
What I have found is that Smart Mailboxes do NOT automatically update themselves. For instance, when a message in the Smart Mailbox is changed in such a way that the filter on that mailbox should not display it, the message will still sit there until I either leave the mailbox and return, or hit Rebuil in the Mailbox menu.
The same applies for when new mail comes into my Inbox. If there is new mail that qualifies for inclusion in the smart mailbox I am currently viewing, it will not appear until I do one of the above two things.
What I discovered was this script:
tell application "Mail" to activate
tell application "System Events"
click menu item "Rebuild" in menu ¬
"Mailbox" in menu bar 1 of process "Mail"
end tell
This is what got me thinking about scripting a solution.
The other option is to assign a keyboard shortcut to the Rebuild command. But I would like the Rebuild to take place automatically when I apply certain rules to messages. I want my Mail Act-on rule to trigger the a Rebuild. I figure I can do this by having it trigger the Rebuild script shown above.
*HERE IS MY QUESTION:*
Is there a way to have the script check what the currently active/selected Mailbox is? Or, put another way, can I get it to NOT run if certain mailboxes are selected?
Here's what I am thinking.
Under no circumstances do I want this script to be triggered if the current mailbox is NOT a smart mailbox, and IS any of my IMAP mailboxes… most especially the Inboxes. That would trigger a complete cleaning out and rebuilding of the entire IMAP inbox, which has many gigs of mail in it.
What I am trying to figure out, and would love some help with, is how I can make sure this script ONLY runs when the current mailbox is either ANY smart mailbox, or NOT an IMAP mailbox, or some other logic that keeps it from running in an IMAP mailbox.
Any tips are greatly appreciated.
With thanks,
Jonathan
Message was edited by: InspiredLife
Message was edited by: InspiredLife
Macbook Pro 17" i7, Mac OS X (10.6.6), 500GB 7200RPM HDD, Matt screen, 8GB RAM