Can't figure out how to click on (+) button in Apple Mail smart mailbox

Hello,

I find Apple Mail smart mailboxes very useful but tedious to configure the mailboxes in large numbers which I need to do as emails from new sources are coming in.
Basically in my smart mailboxes, I define a from: ddd@test.com and located in all inboxes.
attached macro.

  • if I copy the email address of interest, the macro will automatically fill in both the title and the email address following "from".
    My problem is that I want to continue by clicking on the (+) button, after which it is easy (tab → insert text by typing message is in mailbox → all inboxes will automatically populate → press OK button).
    The KBM actions I tried and did not work:
  • click on (+) button
  • click at found image , the image being
    image

thanks in advance for your time and help

New Smart Mailbox.kmmacros (3.5 KB)

Hi Ronald, after filling in the contains field with text (in your example "newsletters@e.economist.com") just do the following:

  • press Tab to select the (+) button
  • press Space to "click" the (+) button
  • press Tab again to move back to the new "Any recipient" field

That should be simple to replicate in KM.

1 Like

I'm not sure about your version of macOS, but I've tried it on 12.8 and I am able to click that + button via AppleScript.

tell application "System Events" to tell process "Mail"
	click button "add criterion" of scroll area 1 of sheet 1 of front window
end tell
1 Like

thanks very much @tiffle !. I should have thought of the spacebar, and you flew in the save the day as usual !

1 Like

thank you very much @royce ! It's a good option.

To make things even simpler, do you think that you could add 1-2 lines to the apple script to

  • actually enter the details of the criterion, meaning selecting "Message is in mailbox" from the dropdown list ? If you do so, "All Inboxes" will automatically populate the mailbox field, and my macro will basically be complete except for pressing the OK button.

  • after that if possible press the OK button (I can also press the OK button with KBM)

Sure, here's how to select the item from the dropdown and click OK. I don't see the option "All Inboxes" that you were referring to, so you'll need to adjust the script below. I'd recommend you get the UI Browser app to help you inspect the actual UI that you need to interact with AppleScript.

tell application "System Events" to tell process "Mail"
	click pop up button 1 of scroll area 1 of sheet 1 of window "Rules"
	delay 0.1
	click menu item "Message is junk mail" of menu 1 of pop up button 1 of scroll area 1 of sheet 1 of window "Rules"
	click button "OK" of sheet 1 of window "Rules"
end tell
1 Like

thanks very much. I thought that UI browser discontinued the app ?

thanks very much. I thought that UI browser discontinued the app ?

You're welcome. The ownership was passed on to the people at latenightsoftware. The original owner is already ~80 and said he wanted to retire after 20 years of maintaining it. I find it really inspiring he kept going for so long.

2 Likes