Copy Subject When Replying to an Email

Hello all,

I have recently discovered Keyboard Maestro and it is awesome. I do not have any programming or scripting background so forgive me if this is really simple for some of you. I am creating a macro, if that is the correct term, to reply to emails I have received from friends whose email address has been used to send me spam or other malware. I was able to borrow some actions from an existing macro called hisender but I wanted to make my macro a little better by including the Subject of the email I had received. I have spent over an hour online looking for this information but was unable to find it. Stated another way in my reply text I want to insert the subject of the email I was replying to. Can this be done by inserting a properly constructed text string or is it more complicated than this?

Hey Bruce,

You’re not describing how your macro works.

What are you starting with?

What’s the trigger?

Yada yada…

Therefore it’s a bit hard to advise you.

The text-token in the “hisender” macro is %MailSender%.

The one for the selected email’s subject is: %MailSubject%

If that’s not a sufficient hint then please post more about your process.


Hi Chris,

I just realized my post was pretty bad. What I did was to modify a macro called hisender.

Here is a screenshot. I figure a picture is worth 1000 words.

What I did was to add more text to the last "Insert Text" macro box after the "%|%". Here is what I was trying to accomplish. About every couple of months I get an email with the email address of someone I know but the email is not from them but linked to spam or malware. In the past I type out an email to these people explaining what had happened. People appreciated being informed about this because invariably they heard from others but I was usually the first to inform them which enabled them to be prepared from others who frequently blamed them for the 'bad' email. When I got one of these this morning I decided to see if I could automate these responses using Keyboard Maestro. My original email was just straight text. Then I decided it would be nice to also let them know what the subject of the 'fake' email was. I though this would be as simple as putting in something like: %Variable%sender_subj%. This is where my ignorance got me in trouble because it is not so simple.

I figured I could create this macro pretty easily then upload for others to use as I figure that this happens to a number of more technically proficient Mac users who are also the first go to tech support for their family and friends. Though I know almost nothing about scripting and macros, I am fairly proficient in other areas of Mac computing.

Hey Bruce,

Much better. Thank you.

What I would probably do is forward the spam email back to them as an attachment.

That way they can see what the real deal is if they want to but be protected from any embedded JavaScript and other junk.

You're using a typed-text trigger to simply insert some text.

Let's do that one better and automate everything.

Spam Informer.kmmacros (7.7 KB)

NOTE: This is made a trifle sluggish by Mail's blasted animation...

This macro can be customized quite a lot of course.



I am really impressed. What you did makes my efforts look so amateurish. Three questions. First, I take it that you have created the KM macro Spam Informer and put in the download link above. May I download this? Second, if I have your permission to download and install it would I be able to edit it? In my case I just to change the hot key combination. Third, would I add it to KM by going to File/Import to Macro Library?

Thank you in advance. I want to contribute to this forum in the future but I am new to this and have only had KM for 3 days. The reason I did not want to forward these kind of emails is that most of the people who are supposed to have sent them to me are not technically proficient at all. I was afraid that if I forwarded the email they might accidentally click on the hyperlinks in the email but what you have done will protected from them from any embedded JavaScript and other junk. I am guessing that somehow your script is stripping out the bad hyperlinks. Very nice.

Hey Bruce,

I've only been using Keyboard Maestro since 2003 and using automation utilities on the Mac since 1985.  :smiley:

Of course.


Double-click the macro file in the Finder, and it will be imported into Keyboard Maestro.

Then move it from the test-group it creates to your Mail group.


There's a menu item in Mail called “Forward as attachment”, and that's what I used.

Unfortunately Mail's AppleScript dictionary doesn't support that, or the macro would be faster.



Thank you again Chris. I have would like to add a final instruction to send the email. The Mail Control/Send Mail Message in KM does more than just sent the email. Is there a simple command I could add at the end of your Spam Informer macro to do this?


You can add this at the end of the macro, maybe with a pause before:

But, unless you are doing this 20 times a day, I would prefer to check the mail before sending it. Just in case anything went wrong with the workflow.

Thank you Tom. I appreciate your point about preferring to check an email before sending it. That is probably what Chris was thinking as well. Thanks to you and Chris I have learned 3 new things today.

Hey Bruce,


The send mail keystroke D is an easy one, so you can preview your email and then send it quite quickly.


Thank you Chris. I like keyboard shortcuts when possible. I try to avoid using my mouse unless absolutely necessary. Funny after all our discussions about building this macro I had another one of these nefarious emails so I was able to use your macro. The way you created the macro was nice because this email required a slightly different response as the email address for the alleged sender was not his real email address.