Macro to move messages in Apple Mail, to replace Mail Act-On?

I am almost sorry to be posting here but Keyboard Maestro is such a rich / robust program that I am finding it hard to get started. I have looked at the manual, I've watched a couple of videos, and still can't find the specific info I need to make my first (what should be) simple macros.

I intend to use KM to replace a Mail plugin that Apple has obsolesced with Sonoma. Mail Act-On (Small Cubed Software) gave me the ability to create keyboard commands to move messages from my inbox to my other countless folders. I have been relying on Mail Act-On for years, but have not been able to upgrade to Sonoma because Apple disable Mail plugins.

All I need from Keyboard Maestro is as set of commands like:

+e < moves msgs to an eCommerce folder
+z < moves msgs to a miscellaneous folder

...and about a half dozen other similar command sets. I do NOT need to record any mouse movements; I just need to record the sequence of keystrokes that move those messages.

But when I try to create these seemingly simple commands with KM.... well, the options are so myriad once I get past creating a folder that I honestly cannot figure out where to start. There are just too many damned options and none of the tutorial I've seen / read so far are getting me to what I need to know.

So I'm asking here. That's what I need to do. Can somebody please steer me directly to what I need?

Now that I've had a look at it I can see that Keyboard Maestro can be a valuable addition to my work flow, but first I have to get it to do what I got it for.

Thanks,

--PS

Do those sequences move messages via Mail Act-on? If not, I don't see how typing "+e" would do anything in Mail. Can you provide more detail on how this works?

If, on the other hand, you're looking to replace that plug-in, wouldn't you need your macro to select the Message > Move To menu, then navigate to and select a particular folder?

-rob.

Hi, and thanks for the quick reply.

With Mail Act-On, once I have selected/highlighted the msg in my inbox, then I just enter the key combinations (ie +e), which commands I create using the MA-P plugin, and the messages get moved to the folder I selected with that command. Is that clearer?

But, yeah, I think you're starting to follow me with the second part of your reply. When creating the Macro (to, yes, replace the plug-in), then โ€“ once a message is selected in my inbox โ€“ I would need the to record the sequence of Message > Move To > and then designate the target folder for that Macro.

Is that any clearer?

Thanks,

--PS (Paul)

Yes, thanks โ€” it wasn't clear to me if you were talking about working with Mail Act On or replacing it. To replace it, you can build your own using Keyboard Maestro's palette feature to present a list of destinations. Here's a simple example that will require editing (obviously, I hope) to work for you:

app-Mail Filing Macros (v11.0.3)

app-Mail Filing Macros.kmmacros (6.7 KB)

This macro group is set to only be active in Mail, and it's set to run as a palette:

I set it on โ‡งโŒƒF, but you can change that hot key to whatever you want. If you click on the Palette Style image, you can customize the appearance of the palette. When you trigger the macro group with โ‡งโŒƒF, if looks like this:

image

The two things in the palette are the two macros in the group; each one of them looks like this:

The "If" condition is used to make sure at least one message is selected; if it is, it then selects the menu items to file it in my Online Orders folder. This macro is triggered by typing an "O," but that only works when the palette is onscreen. The other demo macro is triggered by typing "P," and has the commands to select my Personal Saved mailbox.

To use on your Mac, edit and duplicate the sample macros as needed, assigning each one a one-key shortcut. They will all then appear in the palette, so you can file by pressing โ‡งโŒƒF and then a single key.

There are other ways to tackle this problem, so let me know if this isn't a viable method for you, and let me know if you have any troubles getting it going.

-rob.

1 Like

Thanks for all that. I've had to go off on some other adventures for today, will take a closer look tomorrow.

--PS

Welcome to the forum. I hope you won't mind that I have changed the title of your post, in order to make the thread easier to find for anyone who may be interested.

In addition to @griffman's macro below there is one by @Zabobon that may interest you (I haven't tried it since I don't use Apple Mail). See the thread "Trying to move a Mac mail Message to a folder".

If you are open to the idea of changing to one of the available[1] email clients that support the required functionality as standard, see the thread "Apple Mail: Copying/Moving Emails to Mailboxes by Keyboard (NOT Drag and Drop)" for a discussion.


  1. Plus one by the makers of Mail Act-On that has not yet been released. โ†ฉ๏ธŽ

I don't mind that you changed the subject header, it is more specific, the change overlooks the underlying current: that Keyboard Maestro is SO robust that its functionally is opaque to new users. As I said, creating something as seemingly simple as what I need here should... well, it should be done already. Instead I am still wading through forums and messages and trying to figure out what to do.

--PS

I haven't made it past the first step and I'm already lost:

[quote="griffman, post:4, topic:36725"]
app-Mail Filing Macros (v11.0.3)

app-Mail Filing Macros.kmmacros (6.7 KB) [/quote]

I downloaded that file (app-Mail Filing Macros.kmmacros) and double clicked it, expecting that would install something in KM. What I got was a window in KM:

... that leaves me with no idea what my next move is.

OK, what's "a pallet" ?

I will continue to try to sort this out but, jeezus... I thought it would be easier.

"Everything is intuitive once you know how to do it."

--PS

[quote="griffman, post:4, topic:36725"]
app-Mail Filing Macros (v11.0.3) [/quote]

I'll just post another msg here, at the risk of littering the thread here.

I had the bright idea to close KM and double click the downloaded file. When KM reopened, it brought me to a window like what you're showing here.

So now I see the panels you're displaying but... sorry... still can't figure out what I'm supposed to do.

We're on the same wavelength re: intent here. One of my Act-On's is "Other Stores" - receipts fro online orders that aren't Amazon and other stores I use all the time. The keystroke in Mail / Act-On is [ +e ] and that moves the message to a folder under >eCommerce > Other Stores.

In Act-On, it sorta knows what I'm trying to do and after I've designate 1) the trigger key combo, and 2) the action I desire (move to mailbox) it then give me the ability to drill into my mail folders and select the one I want the messages to go to.

I can kinda see how the file you provided does that, but... I'm still struggling.

Thanks,

--PS

I do this kind of task using Keyboard Maestro (KM) and AppleScript. It's probably a pinch slower than Mail Act-On and may require an extra key press or two, but both of those are helpful bits of friction for me since my fingers and head can sometimes move too quickly for this type of computer interaction.

This Macro allows me to move Mail messages to the handful of Mailboxes I frequently use. I add or replace Mailboxes as my needs change.

I have a Mail-specific KM Macro Group. In that Macro Group I have a Macro that's triggered by pressing the Hot Key Command-F2 and the Macro uses the KM Action called Execute An AppleScript. The macro looks like this:

image

AppleScript presents a list of the Mailboxes I've put in the script, I select the desired Mailbox by typing the first letter of its name, then press Return/Enter, and AppleScript moves the selected Message(s).

Here is the script code, which would need adjustments to replace the Mailbox names I've used (e.g., Doctor) and, possibly, the Account name (iCloud).

	activate
	set theList to {"Vet", "Doctor", "Parents", "Babysitter"}
	choose from list theList with prompt "File Message To..." default items {"Vet"}
	set listchoice to result as text
end tell


if listchoice is "Vet" then
	tell application "Mail"
		activate
		with timeout of 30 seconds
			set theSelectedMessages to selection
			repeat with theMessage in theSelectedMessages
				set theMailbox to "Vet"
				tell application "Mail"
					move the theMessage to mailbox theMailbox of account "iCloud"
				end tell
			end repeat
		end timeout
	end tell
	
else if listchoice is "Doctor" then
	tell application "Mail"
		activate
		with timeout of 30 seconds
			set theSelectedMessages to selection
			repeat with theMessage in theSelectedMessages
				set theMailbox to "Doctor"
				tell application "Mail"
					move the theMessage to mailbox theMailbox of account "iCloud"
				end tell
			end repeat
		end timeout
	end tell
	
else if listchoice is "Parents" then
	tell application "Mail"
		activate
		with timeout of 30 seconds
			set theSelectedMessages to selection
			repeat with theMessage in theSelectedMessages
				set theMailbox to "Parents"
				tell application "Mail"
					move the theMessage to mailbox theMailbox of account "iCloud"
				end tell
			end repeat
		end timeout
	end tell
	
else if listchoice is "Babysitter" then
	tell application "Mail"
		activate
		with timeout of 30 seconds
			set theSelectedMessages to selection
			repeat with theMessage in theSelectedMessages
				set theMailbox to "Babysitter"
				tell application "Mail"
					move the theMessage to mailbox theMailbox of account "iCloud"
				end tell
			end repeat
		end timeout
	end tell
	
else
	tell application "Mail"
		activate
	end tell
	
end if
end

Additional, unrequested information that may be of use:

In the above Macro, the Hot Key used is Command-F2. I want moving a message to a specific Mailbox to be more difficult than opening a specific Mailbox. Which is to say, I have F2 on its own assigned Hot Key to prompt for opening the same Mailboxes that can receive moved messages. The AppleScript for only opening specified Mailboxes looks like this:

	activate
	set theList to {"Vet", "Doctor", "Parents", "Babysitter"}
	choose from list theList with prompt "Open Mailbox..." default items {"Vet"}
	set listchoice to result as text
end tell


if listchoice is "Vet" then
	tell application "Mail"
		activate
		set selected mailboxes of message viewer 1 to {mailbox "Vet" of account "iCloud"}
	end tell
	
else if listchoice is "Doctor" then
	tell application "Mail"
		activate
		set selected mailboxes of message viewer 1 to {mailbox "Doctor" of account "iCloud"}
	end tell
	
else if listchoice is "Parents" then
	tell application "Mail"
		activate
		set selected mailboxes of message viewer 1 to {mailbox "Parents" of account "iCloud"}
	end tell
	
else if listchoice is "Babysitter" then
	tell application "Mail"
		activate
		set selected mailboxes of message viewer 1 to {mailbox "Babysitter" of account "iCloud"}
	end tell
	
	
else
	tell application "Mail"
		activate
	end tell
	
end if
end

This is where I am now:

As you can see I have found my way into what I assume is the panel for creating a macro for my "Other Stores", but... I have no idea what to do next.

When I click on the little green "new action" button, I get this:

... and I have no idea what to do next.

Have I mentioned I thought this would be easier?

<sigh>

--PS

[quote="NaOH, post:10, topic:36725"]
I do this kind of task using Keyboard Maestro (KM) and AppleScript. It's probably a pinch slower than Mail Act-On and may require an extra key press or two, but both of those are helpful bits of friction for me since my fingers and head can sometimes move too quickly for this type of computer interaction. [/quote]

Forgive me if this comes of as frustrated or angry but... this is among several messages that have essentially said "try some other approach..." - like an entirely different mail client or, in this case, by using KM AND AppleScript - with which I have no experience with or interest in learning. That is what I thought a macro app might provide the solution to my now, apparently, not-so-little problem.

Instea, I am coming to the conclusion that I have chosen the wrong program or that my presumption that this would be a relatively simple task was delusional.

Somebody please disabuse me of that notion.

Thanks,

--PS

I would then find the Action for Select Menu by Name (middle column in your screenshot), double click it to add it to the Macro you've begun making, then complete it so the desired Mailbox will be selected.

My mistake: I said to add the Select Menu By Name Action. I should have said the Select Or Show A Menu Item. Once you've completed filling out the Action, you'd have something like this:

image

But where even IS THAT? Your previous post said "in the middle column." But look at the screenshot in my post before that - I do not see "Select or Show A Menu Item" anywhere in that column!

Am I in the right 'category' (Control Flow) even?

I tried to search for "Select or Show A Menu Item" but that result was nil.

So, still struggling.

Still no "first macro."

Thanks,

--PS

You don't see it because in the left-most column you've selected Control Flow. I did not realize that. In the left-most column, select All Actions (at the top), then in the middle column you'll be able to find Select Or Show A Menu Item.

@griffman has given you a couple of macros you can use as templates. Duplicate one, rename it, give it a single-character hot key trigger that is different to the others. Then change the "Menu Item" field to match the name of the mailbox you want to move mail to:

Edit Mail Action

Because it is in the same Group as the others it will automatically appear in the palette you get when you use the Group's hot key trigger.

Ah, OK, now I feel like I'm starting to get some where. I thought it would show up if I Searched, but now I have found it under All Actions (and jeez, what list!)

So here is where I am now:

NOW my previous... experience... intuition... tells me to find the button to SAVE this Macro... but... don't see such a thing. Does it Save automatically somehow?

I thought maybe I could answer that question by testing the HotKey combo, but that gave me:

... which I think is actually Mail Act-On telling me it doesn't recognize the command.

Not I am (finally) starting to get some sense how this works, I will take another look at @griffman 's samples and see if I can get that to work (the "Pallette" seems like it would be useful)

I guess the question at the moment is: do I need deactivate Mail Act-On to get any of this to work in Mail?

Hmmm... I have already installed Sonoma on another computer that does not use Mail Act-On, maybe I should try there first.

Thanks,

--PS

Speaking of @griffman 's Pallette: I AM still working within the Group/Palette he provided, but I don't know if the new Macro I just created will appear in the Palette. Is there something I can/should do to add it to the Palette?

You should give each new macro you create a single key shortcut. The overall macro, as I wrote it, is triggered when you hit Shift-Control-F. That presents the palette which will show any macro within the group. And next to each macro the single key shortcut you assigned will appear. Press that key and the selected message(s) will be moved to the mailbox in the macro.

And that's the key: There's no magic integration with Mail, you have to enter the name of each mailbox you want to use in each macro you create. And due to the limitations of how Mail's menus work, if two mailboxes have the same name, I'm not sure which one it'll get moved to.

I don't know if @Nige_S' AppleScript works around that issue or not, as I don't do much mail filing so haven't tried his macro.

-rob.