Macro to fix an empty subject line bug in MailButler

Hi Smart People,
There’s a bug in MailButler where in Apple Mail random Exchange messages don’t include the original subject line when you hit reply or forward. The MailButler support team worked hard with me on this one and claim that it’s fixed for High Sierra. But upgrading from Sierra isn’t an option right now.

SO, I was exploring creating a macro that I could trigger (or better still, might be triggered) when one of these empty subject lines shows up that would copy and paste in the subject line from the original message. I’m having a problem with getting to that text in Mail using keyboard shortcuts; I can use the trackpad, but it seems hard to reproduce as an action for a Macro. I’d welcome any advice.


We need more information to be helpful.

  1. A screenshot, or better, an animated GIF, showing the process and where you want to invoke a KM macro
  2. What is MailButler? I could google, but it’s better if you provide a link, and describe what its role is in this process.
  3. Provide step-by-step the process that leads to the empty subject line. Start at the beginning after you have opened Apple Mail and/or MailButler.
  4. State your versions of KM, Mail, MailButler, and macOS.

If you don’t have a tool to create animated GIFs, here’s a pretty good one that is free:

Hey Pommette,

This is doable but difficult.

AppleScript access to Mail’s reply and forward functions is poor, so you really have to use System Events and GUI-Scripting.

The basic recipe would be:

Replace Mail’s Reply keyboard shortcut with a Keyboard Maestro macro.

The macro would:

A) Copy the subject of the selected email to a temporary variable.
B) Activate Reply (or Forward).
C) Check the subject field to make sure it is not empty.
D) If the subject field is empty then populate it from the temp variable.

I have a Smart Reply macro bound to R that makes changes to the reply message based on who the sender is.

I.e. — I do this sort of thing routinely.

The simplest thing for you to do would be to use a macro to take over the reply function and copy the subject line to the clipboard using a bit of AppleScript.

That way when the subject line is unpopulated you could just tab into the subject field and paste.

# Auth: Christopher Stone
# dCre: 2017/10/17 23:35
# dMod: 2017/10/17 23:40
# Appl: Mail
# Task: Get subject from selected email in Mail and place it on the Clipboard.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Mail, @Message, @Subject, @Selected, @Email, @Clipboard

tell application "Mail"
   set selectedMessageList to selection
   if length of selectedMessageList = 1 then
      set selectedMessage to item 1 of selectedMessageList
      tell selectedMessage
         set subjectText to its subject
         set the clipboard to subjectText
      end tell
   end if
end tell



1 Like

It is good to have you back, Chris. Your wisdom and expertise in Applescript and Apple Mail (just to mention two of many) have been sorely missed.

Dear Chris, Thanks a million for this, and apologies for not jumping on this right away – it was buried in the avalanche of life. Would you mind sharing each step for this, assuming that you’re responding to a newbie? Right now I set up the shift-option-command-R (the equivalent of your command-shift-R as the trigger, followed by an applescript action where I pasted in the script you provided. But nothing happens. But I’m not exactly sure when I’m supposed to use the shortcut. (I tried it when I’d normally hit command-R to reply to a particular message, but that’s where nothing happened. I suspect I’m missing a step. Thanks again!