DC 6.0 Example - Sending emails

Most of this guide has moved to: DC 6.0 Mail Templates. In order to avoid duplicaiton of documentation, it has been removed from this guide.

This is a small walkthrough of how to send emails with Digizuite Automations. In this walkthrough, we will setup an automation to load a set of assets, and then send of an email.

Creating the automation to send the email

This walkthrough focused mostly on the mail template, and will not dig into the details about how AW work, but will use a simple example for testing.

First create a trigger, in this example I’m listening for a change on the English description field. Normally you might use something like a Cron trigger to start the automation, so it can run on a schedule.

 

Next I’m using a search to load the assets i want to display. I’m just using GetAssets here, since that search comes with the dam center. Normally you would want to make a custom search, so you can find just the assets you want to show.

Then i need to extract the asset ids from the json:

Next comes an oddity. Because the mail template automation takes a list of items, it needs them formatted as a list it can parse. The way automation currently deals with this, is splitting the values on comma (,). So we need to create a string from the asset ids, separated by comma. We can do this using the Join Strings action:

Then we need to actually invoke the Send mail to member action:

We are going to be going through this action in detail, since it really is the meat of the automation.

First we have the Receiver Member Id, which is simply the member id of the user who should receive this email. If you want to send an email to multiple users, you should invoke the action multiple times, once with each member id.

Next is the Template Name, which is the name you gave your email template.

After that is the Config Version Id, which is the config version id from the config manager you want the email to be send from. If you simply created your template in the root config version, then any values here will work, as long as it is a valid hierarchy id, for example /0/.

Lastly is the Mail Data, which is the data that is passed along to the template. The syntax is a key-value syntax, which looks like this (key),(value). The key is what the name of the property on the data object will be in the mail template. The value is the data you want to pass along as a list. Data is always pass along as a list in the mail system. You can pass multiple key-value pairs along should you wish to. The ordering of the values will be preserved, when passed to the mail template.

This should be everything you need in order to have your system working.

Good practices

Check if result is not-empty:

Users generally don’t want to be notified if nothing happens, so it is a good idea to check that the result returned by the Find Asset in the automation is not-empty before triggering the mail template.

Cap the limit of search results

If you cap the items send in the mail template, you might as well also cap the search result in the automation. You can do this by adding the Mac Result Count to be 1 more than the cap in the mail template.

Note, scriban only allows a loop of max 1000, otherwise it will fail. Thus limiting the search result to 1000 is always a good idea.