Skip to main content

Send Email

Use the Send Email step to send an email from a flow. The step uses Business Central's standard email module – the same one that powers the Email Accounts page and the document email actions – so configured accounts, scenarios, and outbox handling are all reused. No own SMTP stack is introduced.

Typical use cases:

  • Sending a generated invoice PDF to the customer after a Create PDF Document step.
  • Posting a notification to a team mailbox when an order ships.
  • Escalating overdue items to an admin address from a scheduled flow.

Configure the step

Open the flow editor, add Send Email, and fill in the configuration page.

Description

  • Purpose: Describe what this step does in the context of your flow.
  • When to fill it: Always. Shown in the editor and execution history.

From

  • Purpose: The email account used to send the message.
  • When to fill it: Required.
  • How it works: Click the assist button to open the Email Accounts picker. Only accounts registered in this company are listed. Both the account ID and its connector are saved in the step configuration.
  • Tips: If no accounts appear, set up email under Set up email in BC first. The step does not create or modify accounts; it only consumes existing ones.

To

  • Purpose: Recipient addresses on the To line.
  • When to fill it: Required (or use CC / BCC instead – at least one of the three must be set).
  • How it works: One or more email addresses, separated by ; or ,. SmartFields are resolved when the step runs, so {{customer.email}} produces the customer's email at that point.

Subject

  • Purpose: The subject line.
  • When to fill it: Required.
  • How it works: Plain text. SmartFields are resolved when the step runs.

Body

  • Purpose: The HTML body of the email.
  • When to fill it: Required.
  • How it works: Format with bold, italic, lists, links, tables, and images using the toolbar (BC's standard Rich Text editor). SmartField placeholders like {{customer.name}} are resolved when the step runs. To insert a SmartField, click Insert SmartField (Alt+S) – the picker copies the placeholder into the clipboard so you can paste it anywhere in the editor.

Attachments

  • Purpose: Files to attach to the email.
  • When to fill it: Optional.
  • How it works: Each row is either a Reference selector or an Inline entry:
    • Reference points to a SmartField that resolves to one – or an array of – mse365 AF Document records. Each resolved record becomes one attachment, using the document's name and content. This is how you attach a PDF generated earlier in the flow by Create PDF Document.
    • Inline carries an explicit filename plus the content as base64-encoded text. Useful when an upstream step (HTTP request, parser, etc.) already produced a base64 payload.
  • Tips: When the reference selector resolves to an empty array, the email is sent without attachments. The step does not enforce a size cap; the email connector / SMTP layer rejects oversize messages with its own error.

CC / BCC

  • Purpose: Carbon-copy and blind-carbon-copy recipients.
  • When to fill it: Optional. Hidden behind Mehr anzeigen.
  • How it works: Same shape as To. SmartFields supported.

Output

The step returns one value output:

  • sentEmailId – the GUID of the sent message. This is the same identifier used as Sent Email."Message Id" in BC's Sent Emails table, so you can use it to look up or link to the entry from a downstream step.

What happens when the step runs

  1. The step reads its configuration (account, recipients, subject, body, attachments).
  2. AutoFlow Setup → Test Mode is checked – see below.
  3. Recipients are validated for well-formedness (each non-empty entry must look like an email address).
  4. The configured email account is checked for active registration; if missing or inactive the step throws.
  5. Attachments are materialised: reference selectors are resolved against the SmartField context, each mse365 AF Document record contributes its filename + content; inline rows are base64-decoded.
  6. The message is built via Codeunit "Email Message".Create (HTML body), attachments are added, and Codeunit Email.Send delivers the email synchronously.
  7. The message GUID is exposed as sentEmailId.

Test mode (AutoFlow Setup)

On the AutoFlow Setup page there is a Test Mode group with two fields:

  • Test mode (redirect comms) – when enabled in a sandbox or test tenant, every Send Email step in this company redirects To / CC / BCC to the configured test recipients instead of the real addresses.
  • Test mode email recipients – the comma- or semicolon-separated list of test addresses.

Use this to keep test runs from delivering to real customer mailboxes. The redirect is logged in the step log so you always know it happened.

Error handling

Any of the following raise an AL error and abort the step:

  • Empty recipients (To / CC / BCC are all blank).
  • Invalid email address syntax.
  • The configured email account is missing or no longer registered.
  • The reference selector points at the wrong table or a non-existent record.
  • The inline attachment's base64 content is malformed.
  • The email connector or SMTP layer rejects the send.

For in-flow recovery (catching the error and continuing on a separate edge), use the upcoming Guarded Steps mechanism on the action step – when active, send errors land on the _errorMessage output and the On error edge fires.

Reply-To

Reply-To is not supported in v1. BC's public AL email API (Codeunit "Email Message") has no SetReplyTo method, and OnBeforeSendEmail hands you an Email Message object that does not expose Reply-To either. We will add this field as soon as Microsoft adds platform support.

Best practices

  • Use SmartFields for addresses, subject, and body – this is what makes the step useful across customers and contexts.
  • Set test mode in sandbox tenants before importing production flows – so test runs never deliver to real customers.
  • Chain Send Email after Create PDF Document – use the PDF step's Document reference output as a Reference selector on an attachment row. This is the canonical way to email generated documents.
  • Attach an array of documents by pointing a Reference selector at an array-typed SmartField – e.g. the iterator of a For-Each loop. Every iteration's document becomes one attachment.
  • Use Sent Emails to inspect history – the sentEmailId output is the message GUID, also available on the standard Sent Emails page in BC.