As Apple Mail users know, KM actions have to deal with the shapeshifting done by the open/closed status of folders within folders.
I have tried long and hard to write a KM macro that addresses this, but am obviously lost, per the attached.
I want KM actions to cascade according to the aforementioned status.
I'm running Apple Mail v16 on Sonoma, but this has been an issue for long before that.
In fact, the "Apple Mail - Send Selected Email(s) to a Particular Mailbox" explains the pickle much better than I can, but doesn't offer a solution I understand. It seemed that a macro dependent on KM actions' success or failure is better than depending on Apple.
I am not an expert at KM, but I think I see a mistake in your code. Your first IF statement looks fine, because the previous statement is the Select action. But your second IF statement seems to have a problem, because it doesn't follow a Select action, but instead follows an IF action. As the wiki page says:
The %ActionResult% token returns text indicating the success or failure of the immediate past action.
That word IMMEDIATE means the immediate previous action. Do you see the issue?
Can you write down what you are trying to achieve? I think it's
if there is a mail folder "Read 24" inside "Read 15 -" inside "iAssCloud PPS 20230625"
move the email to it
else
if there is a mail folder "Read 24" inside "Read 15 -"
move the email to it
else
move the email to mail folder "Read 24-"
end if
end if
If so, it might be easier to test for the existence of the folders then move the email, rather than relying on the success/failure of previous actions.
Airy - I do not see the issue that you mentioned, but did some tweaking to the macro (attached) which I THINK addresses it? Please advise.
Nige-S - "Cascade" may be my use of the wrong term.
The pickle is this: Apple Mail's folder status changes as a destination depending on whether overarching folders are open or closed, so the "Move Message…" must "check" to see which state the folders are in.
I am attempting to do that with an IF - THEN approach, and it may not be the best way.
Per my original post, I see others have run into the Apple Mail "chameleon" folder issue, but don't see a solution.
I'm not seeing that -- "closed" folders still show their sub-folders in the "Move To..." menu for me, at least 4 levels deep (I did want to add any more in case the act of adding them caused a refresh that made them visible!).
Perhaps it depends on the mail provider and the way folders sync? You aren't, by any chance, looking at a Gmail account? (I've looked on both "proper" IMAP and Exchange, and they both seem fine.)
The difference in how KM "sees" open/closed nested Apple Mail folders is a known conundrum (see above "Apple Mail - Send Selected Email(s) to a Particular Mailbox"), so you must be blessed.
To be clear: I'm talking about open/closed folders in the sidebar on the left -- it most definitely affects how KM views the "Move to…" issue.
The examples are pretty much the "actions" in my macro, each addressing a different open/closed-in-sidebar status.
Thankfully, now that I've got the macro working, I can apply it to other mailbox management issues I was having.
Nice try, but I'm sorry to say that that's still not right. Let me paste an example that should work. Notice how each of my IF statements immediately follows the Menu action. I will leave it to you to fill the Menu actions with the correct values. Does this help?
I'm glad you tried to solve it yourself. I think anyone who helps others is always pleased to see the other person giving it a try. Other people have suggested other ways to solve this problem, which are perfectly valid as well, but if you want to use my suggestion, that should work just as well. It's always up to you to decide which method you want to use.
Ah yes, I see where you are coming from now. Not so much "blessed", more "different way of working".
And, TBH, if it was a problem for me I'd take the alternate approach mentioned in the thread you referenced -- AppleScript it. Depending on your needs it could be as simple as:
tell application "Mail"
set theEmails to (get selection)
set theAccount to (account of mailbox of item 1 of (get selection))
repeat with eachItem in theEmails
move eachItem to mailbox "Test 4" of mailbox "Test 3" of mailbox "Test 2" of mailbox "Test Mailbox" of theAccount
end repeat
end tell
...although the exact script will depend on your setup, whether you use multiple accounts and the unified Inbox, want a single archive folder (maybe "On My Mac") for all accounts, and so on. And you can get clever, deciding within the script which folder to move each email to based on content, metadata, etc.
Pop the script into a KM "AppleScript" action in your macro, set a hot key trigger -- then it doesn't matter what state your sidebar is in, the messages will be moved.