Is This Possible to Do With Keyboard Maestro or a Bit Too Involved?

I'm wondering if this is possible and if it is, if I might get some help to create it.

I use the email program Airmail 3 on my Mac. I frequently need to email things into the helpdesk of my company. It must be done in a very particular way.

I must insert the keyword β€œ#original_sender" followed by the customers email address at the top of the email body.

It would look like this:

#original_sender {email@email.com}

What would be wonderful is to click forward on an email and then trigger a command that would copy the email out of the top of the forwarded email and the whole thing in the line above at the top of the email.

Here is the way a forwarded email looks.

On October 25, 2022 at 11:57:41 AMTue, Don Juan (don@juan.com) wrote:

Interested

So with the way it needs to be done it would look instead like this:

#original_sender {don@juan.com}

And below would be the original email.

What would be wonderful is to have a few letters I could click and the email forwarded, the helpdesk email pasted into the right spot, then the words with the clients email formatted correctly is inserted at the top of the body of the email.

Please let me know if this kind of thing is possible.

Thanks

Anyone?

Most things are. This will be a lot easier, and a lot more reliable, if you can use AppleScript rather than trying to click buttons or activate fields and paste text.

Airmail is currently version 5. Are you still using v3 or is that a typo? If you are, then does v3 have AppleScript support? If you've stuck with v3 (perhaps because they moved to a subscription model after that) then you might have have trouble finding someone who also has that version...

Yes you are right. That was a typo. I am using Airmail version 5.

Is this something you might be able to help me with or do I need to look in some other way?

Unfortunately, while Airmail is a free install there is no free version (there's a "3 day free trial", but that's a "subscribe then cancel" which I am not going to do). And Airmail's AppleScript dictionary is very limited -- there's no "Forward" command, for example -- so I think you might have to resort to UI manipulation.

You should, at least, be able to get the sender of a selected message via AppleScript. Until then you could try something like the following:
Highlight the original sender address, like you were going to Copy it, then trigger a macro that:

  1. Copies the address to the Clipboard
  2. Does a βŒ˜β‡§F key stroke to "Forward" the message -- a new outgoing message will probably open
  3. In most email apps the insertion point will be in the "To" field -- use Tab or ⇧Tab keystroke actions to position the insertion point if it isn't in the right place
  4. Use an "Insert Text by Typing" action to insert your help desk's address
  5. Use multiple Tab keystroke actions to get the insertion point into the body of the message, and a ← keystroke if the body text is selected on entry
  6. Use an "Insert by Pasting" action or similar to to add your #original_sender text with the email address you copied (or got via AppleScript) at the beginning
  7. When everything's done, use a βŒ˜β†© keystroke action to send the email

Difficult to be more specific without the software, but that should be enough to get you started (at least until another Airmail user steps up). Give it a try, and if you get stuck try another post but with "Airmail" in the title so you attract the attention of the right people.

1 Like

That is really helpful. Thank you.

You could also have Keyboard Maestro do the βŒ˜β‡§F, and then Select All (⌘A), and then Copy, and then Keyboard Maestro could find the address by searching for the β€œOn … wrote:” line.

Then Up Arrow to deselect, and Insert Text by Typing to insert the original_sender line.

2 Likes

Thanks I'll try it.