I have a lot of accounts in Mail. I use KeyboardMaestro to automate much of what I do, but I haven't found a way to reliably get it to choose a given account in a new message window. I'm wondering if I can get applescript to do it for me.

I have the following:

tell application "Mail" to make new outgoing message with properties {sender:"[email protected]"}

and Mail obediently opens a new message window...but doesn't bother to set the sender correctly :-(

I've also tried using the entire string which appears in the Sender popup menu in the window (which seems to be the Alias, in the Accounts pane of Mail's prefs window), plus just the substring before the hyphen (which seems to be the Full Name in Mail's prefs). Nothing works.

Has anyone managed to get this to work?

1 Answer 1


From here

Slightly different format for the sender property.

tell application "Mail"
  set theOutMessage to make new outgoing message with properties {visible:true}
  tell theOutMessage
      make new to recipient at end of to recipients with properties {address:"[email protected]"}
      set sender to "FirstN LastN <[email protected]>"
      set subject to "Message Subject"
      set content to "Message Text"
  end tell
end tell

So yours would be...

tell application "Mail" to make new outgoing message with properties {sender:"FirstN LastN <[email protected]>"}

You can find and edit the FirstN and LastN in System Preferences>Internet Accounts>[Email Name]>Details>Name

  • Uh, no, I want to set the SENDER, not the recipient :-)
    – skiaddict1
    May 30, 2018 at 21:09
  • Oh I misread will edit
    – JBis
    May 30, 2018 at 22:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .