Skip to main content

Email Target

The email target is a built-in automation target that sends an email notification whenever an automation condition is triggered. A variant is also available that delivers the triggered data as a file attachment.

Built-in targets

Built-in targets are provided by OpenDataDSL and referenced using the @ prefix on their script name (e.g. @EmailTarget). They are available to all tenants without any additional configuration.

Available email targets

CodeNameDescription
emailSend an emailSends a notification email to one or more recipients
email_attachmentSend an email with an attachmentSends the triggered data as a file attached to an email

email — Send an email

Use this target to send a plain notification email when an automation fires. The email body is generated from the event data using the configured template.

Inputs

InputRequiredDescription
toThe email address(es) of the recipient(s). Separate multiple addresses with ,, ;, or a space
subjectThe subject line of the email

Using this target in an automation

//#region Notify on dataset late
ab = AutomationBuilder("dataset", "private", "MY_PROVIDER.FEED.PRODUCT")
ab.addCondition("late")
ab.setTarget("email")
ab.setProperty("to", "ops-team@example.com")
ab.setProperty("subject", "Dataset late: MY_PROVIDER.FEED.PRODUCT")
ab.icon = "envelope-at text-outlook"
ab.enabled = true
save ${automation:ab}
//#endregion

Sending to multiple recipients

You can notify several recipients by separating addresses with a comma, semicolon, or space in the to field.

//#region Notify multiple recipients on curve build failure
ab = AutomationBuilder("curve", "private", "MY_CURVE_OBJECT:CLOSE")
ab.addCondition("failed")
ab.setTarget("email")
ab.setProperty("to", "ops-team@example.com,data-team@example.com")
ab.setProperty("subject", "Curve build failed: MY_CURVE_OBJECT:CLOSE")
ab.icon = "envelope-at text-outlook"
ab.enabled = true
save ${automation:ab}
//#endregion

email_attachment — Send an email with an attachment

Use this target when you want to deliver the triggered data as a downloadable file. The data is serialised and attached to the email using the name you configure.

Inputs

InputRequiredDescription
toThe email address(es) of the recipient(s). Separate multiple addresses with ,, ;, or a space
subjectThe subject line of the email
attachmentNameThe filename used for the attachment. Defaults to the ID of the triggered entity. Supports embedded date expressions
Attachment names with dates

You can embed date expressions in the attachmentName to make filenames dynamic — for example, MY_DATASET_${yyyyMMdd}.csv will resolve the date at the time the automation fires.

Using this target in an automation

//#region Send dataset data as an email attachment on completion
ab = AutomationBuilder("dataset", "private", "MY_PROVIDER.FEED.PRODUCT")
ab.addCondition("complete")
ab.setTarget("email_attachment")
ab.setProperty("to", "analyst@example.com")
ab.setProperty("subject", "Dataset ready: MY_PROVIDER.FEED.PRODUCT")
ab.setProperty("attachmentName", "MY_PROVIDER.FEED.PRODUCT_${yyyyMMdd}.csv")
ab.icon = "envelope-paper text-outlook"
ab.enabled = true
save ${automation:ab}
//#endregion

Using the default attachment name

If you omit attachmentName, the attachment is named after the ID of the triggered entity. This is useful for quick setups where a fixed name is sufficient.

//#region Send curve data as an email attachment on successful build
ab = AutomationBuilder("curve", "private", "MY_CURVE_OBJECT:CLOSE")
ab.addCondition("success")
ab.setTarget("email_attachment")
ab.setProperty("to", "analyst@example.com")
ab.setProperty("subject", "Curve ready: MY_CURVE_OBJECT:CLOSE")
ab.icon = "envelope-paper text-outlook"
ab.enabled = true
save ${automation:ab}
//#endregion

Transforming data before sending

Both email targets support the @transformer property, which lets you reshape the triggered data using a mustache script before it is attached or embedded in the email. This is useful when recipients expect a specific format such as CSV or HTML.

Set @transformer to the ID of a mustache script stored in the platform:

//#region Send a CSV-formatted attachment on dataset completion
ab = AutomationBuilder("dataset", "private", "MY_PROVIDER.FEED.PRODUCT")
ab.addCondition("complete")
ab.setTarget("email_attachment")
ab.setProperty("to", "analyst@example.com")
ab.setProperty("subject", "Dataset ready: MY_PROVIDER.FEED.PRODUCT")
ab.setProperty("attachmentName", "MY_PROVIDER.FEED.PRODUCT_${yyyyMMdd}.csv")
ab.setProperty("@transformer", "example-odsl\\0.DEMO\\DefaultTemplates\\AutomationObject_CSV")
ab.icon = "envelope-paper text-outlook"
ab.enabled = true
save ${automation:ab}
//#endregion

See Advanced automation features for more detail on the full set of @ properties available.


Choosing between the two targets

emailemail_attachment
Use whenYou need a notification onlyYou need to deliver the data itself
AttachmentNoneData serialised as a file
Attachment nameN/AConfigurable, defaults to entity ID
Iconenvelope-at text-outlookenvelope-paper text-outlook