Send mail
Sends an email through the Mail app, or opens a draft for you to finish.
Send mail to to
Keyboard Maestro: MailSendMessage
Details #
Builds a new outgoing message in the Mail app and, by default, sends it. Mail must have an account set up. Switchboard talks to Mail with AppleScript, so the message goes out from whichever account Mail chooses, or from the sender you name in account.
to, cc, bcc and attachments each take either a list or one piece of text. Text is split at commas, semicolons and line breaks, so [email protected]; [email protected] is two recipients. Every address must contain an @. Attachments are file paths; ~ is expanded.
With send left at true, the message is sent in the background and no window opens. With send set to false, Mail comes to the front with the draft open and nothing is sent. That is the safe way to try a macro, and the only mode that works with no recipients.
The step has no output. The Trace note says who it was sent to, or that a draft was started.
Parameters #
| Parameter | Type | Required | Values | What it does |
|---|---|---|---|---|
account | text | The sender to put on the message, set as the message's sender in Mail (normally the account's email address). If Mail does not accept it the setting is ignored and Mail picks one. | ||
attachments | any value | File paths to attach, as a list or as text separated by commas, semicolons or line breaks. Every file must exist. | ||
bcc | text | Blind copy recipients, same format as to. | ||
body | text | The message text. text is another spelling of body. | ||
cc | text | Copy recipients, same format as to. | ||
send | yes / no | true (the default) sends the message. false opens it as a draft. | ||
subject | text | The subject line. Empty by default. | ||
text | text | Same as body. If both are given, body wins. | ||
to | text | Recipients, as a list or as text separated by commas, semicolons or line breaks. Needs at least one address across to, cc and bcc when send is true. |
Every step also accepts label, onFailure, timeout and dryRunSafe.
Examples #
- Start a mail to “[email protected]”
- Show “Draft started”
Gotchas #
The first time, macOS asks whether Switchboard Engine may control Mail. If you decline, the step fails; turn it on again in System Settings > Privacy & Security > Automation.
Fails with
"x" isn't an email addresswhen any recipient lacks an@.Fails with
mail.send needs at least one recipient (to, cc or bcc); set send to false to just start a draftwhensendis on and nobody is listed.Fails with
the attachment <path> doesn't existwhen a file is missing.Mail has no way to report a delivery failure afterwards, so a step that passes means Mail accepted the message.