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:"my@email.address"}

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?

up vote 0 down vote accepted

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:"first@mail.com"}
      set sender to "FirstN LastN <josh.stackexchange@gmail.com>"
      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 <my@email.address>"}

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 at 21:09
  • Oh I misread will edit – JBis May 30 at 22:09
  • Awesome, thank you very much :-) – skiaddict1 May 31 at 1:09

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.