Skip to content

Outlook Send Email

Type: outlook-send  ·  Package: Outlook Activities v1.0.5

Sends an email through Outlook. It supports several recipients, carbon copy (CC) and blind carbon copy (BCC), plain-text or HTML body, and attachments. Useful for notifications, reports, confirmations. Since it uses the account configured in Outlook, you need no server or password in the playbook, and the email is kept in Sent Items.

It composes the email and sends it right away:

  • Account: if there is an Outlook Connect session with account and that account exists in the profile, the email goes out from it; otherwise, from the default account.
  • Recipients: to, cc and bcc accept a text with the addresses separated by semicolons (;) or commas, or a list of addresses (since version 1.0.5; before, a list made the send fail). Outlook resolves each entry as if you had typed it (address or address-book name).
  • Body: if you set htmlBody, it is used and body is ignored. If you set neither, the email has no body.
  • Attachments: paths that do not exist on disk are skipped (the log says how many) and the email is sent anyway.
ParameterTypeDefaultDescription
tostring | List—Recipient(s): text separated by ; or ,, or a list of addresses (list since version 1.0.5).
subjectstring—Email subject.
ParameterTypeDefaultDescription
sessionZoanOutlookSession—Session from Outlook Connect. Inherited inside the Connect body; without a session the default account is used.
ccstring | List—CC recipients: text separated by ; or ,, or a list.
bccstring | List—BCC recipients: text separated by ; or ,, or a list.
bodystring—Plain-text body.
htmlBodystring—HTML body. When set, it takes precedence over body.
attachmentsstring | List—Path of a local file or list of paths to attach. Empty or missing paths are skipped.

This activity does not return a value. The log says how many recipients the email was sent to.

MessageCause and fix
'to' is required.to is missing or the expression returned null.
Outlook error when resolving recipientsAn entry in to/cc/bcc is neither a valid address nor an address-book name. Check the text and the separator (;).
Outlook error when sendingOffline, account without send permission, or attachment blocked by size or type. Check Outlook on the robot’s machine.
COM component 'Outlook.Application' is not registered. Is the application installed?Outlook is not installed on the robot’s machine.

Email with the invoice attached:

Outlook Send Email
to = "customer@company.com"
subject = "Invoice " + invoiceNumber
body = "Please find your invoice attached. Thank you."
attachments = arr("C:/invoices/" + invoiceNumber + ".pdf")

HTML email with CC, from a list of recipients:

Outlook Send Email
to = recipients
cc = "supervisor@company.com"
subject = "Daily report"
htmlBody = "<h1>Report</h1><p>Processed: " + total + "</p>"