I have been building a macro to dynamically generate a menu and based on user selecting a number (originally 1-9) it would file an email in a specific folder. I started to expand the macro with additional cases, but now with the number 10, it never seems to match that case even when I can see the variable is set to 10 before entering the switch. In reviewing with matcher, I noticed that there seems to now be a "is=" condition which I can't find documentation on. Previously I had used "contains" which breaks since "1" will match "10", but switching to "is" never matched and "is=" somehow never even hits the "otherwise" condition, so I can't tell what is happening.
Thanks for both responses, I was starting to look at how to sanitize the macro and in the process that what I thought was the problem may actually be wrong. The mail folders are nested and in general I don't keep everything expanded. Mail has a nuance where the menu for moving messages dynamically varies by what is visible based on the currently expanded folders. Anything which is still nested requires navigating through the sub-menus.
What I seem to be finding is that the items which have a problem are the ones which are nested a few layers deep. Although the select menu items let's me navigate down to the specific folder, it seems that they don't reliably work. I think the initial switch case issue was mostly a red herring based on an initial bug in my code, and now I'm working on a different problem.
I'm not sure if I need to insert a delay of some sort (if that's possible) to let the UI keep up with the navigation through the menus. Here is the Macro in case I'm wrong and instead missing some other obvious problem.
Thanks for the pointers. This is daily processing 200-300 emails a day. They are being filed within IMAP on Big Sur. I'm going follow on your Apple script idea. It looks like in AppleScript the mailbox name doesn't require any understanding of the folder structure. so I can just call the name directly. Does this look like what you were thinking for the move piece?
tell application "Mail"
set tgtMailbox to (first mailbox whose name is "Project 1") of account "Work"
set selMessages to selected messages of message viewer 1
repeat with selMessage in selMessages
set mailbox of selMessage to tgtMailbox
end repeat
end tell
I spent some time testing on both my Sierra and Mojave machines, and I'm sad to find out that Mail is still egregiously slow when filing multiple messages with AppleScript.
I think filing 30 messages took around 10+ seconds on both of my systems.
Preposterous! Mail Act-On and MailHub can do it in a flash.
When doing this many times per day the sluggishness may become oppressive.
If the AppleScript works satisfactorily for you then great – if not then there's an alternative.
You can drag and drop mailboxes in that space and move them around with Cmd-drag.
They show up in the Mailbox › Move to Favorite Mailbox menu with assigned keyboard shortcuts:
You can use these keyboard shortcuts directly, or you can reassign them using the system keyboard preferences or Keyboard Maestro.
You can also assign keyboard shortcuts to mailboxes in the menu structure by name, as long as the name is unique. Even if the mailbox moves around in the menu due to the arrangement of the side-bar, the keyboard shortcut will stick with it.
Thanks for all the time you have spent looking at this. I think I've been lucky so far that in general I'm not batch processing emails, but reading and filing so I may not notice the delay as much since I'm reading the next email. I didn't know the trick with the favorite email folders, which is really nice. I'll need to spend some time looking at the two apps you recommended as longer term solutions.
Thanks again for all your time spent looking at this.