Configure an automation bot to send an email to one or more recipients based on an event by using the Send an email task.
For example, if an employee sends a request for a new chair (the event), you can configure the bot to send an email to their manager requesting approval before fulfilling the request.
To send an email from a bot, add and configure the Send an email task based on the email type, as described in the following sections:
- Email types
- Add and configure the Send an email task
- Add email recipients
- Examples of sending an email from an automation
- Prevent app creators from adding email attachments in automations
See also Tasks: The Essentials.
Email types
There are currently two types of emails that you can configure:
Email type | Description |
Embedded app view (dynamic) | Embedded app view emails enable you to embed supported app views within an email and allow Gmail recipients to interact directly with your app from within the email, without leaving their inbox. To configure an embedded app view email, see Send embedded app view emails from an automation. |
Custom template | Custom template emails allow you to configure emails with text, HTML, or variables from app data. Configuration details are provided below. |
Add and configure the Send an email task
Add and configure the Send an email task by performing the following steps:
-
Add the Send an email task to a bot, as described in Add a task to a bot.
-
Configure the Send an email task by using the settings described in the tables below.
-
When you are done, save the app by selecting one of the following:
- Save - Save the app.
- Save & verify data - Save the app and verify that it is runnable based on external dependencies.
-
To preview the email, click Preview email.
The first record in the table is displayed, by default. You need to save the app to preview the latest changes.
After you save the app, you can reuse the task in other bots.
Configure the Send an email task by using the settings described in the following tables.
Setting |
Description |
Linking | Enable or disable reuse of this component by expanding the Linking panel and toggling the Linking setting. See Reuse automation components. |
Task name |
Name of the task. It must be unique within your app. |
Email Type |
Email type. Click Custom template. Note: To configure an Embedded app view email, see Send embedded app view emails from an automation. |
Table name |
Table defined in the event and used by the task. To view or edit the structure of the selected table, position your cursor in the field and click . See Tables: The Essentials for more information. Note: To use a table that is different from the table defined in the event, add a Call a process step. |
To |
List of email recipients. Enter an email address or an expression using the Expression Assistant. Click Add to add additional email recipients. See Add email recipients for more information. |
Email Subject |
Subject of the email. Specify text, variables, and expressions. For example:
By default, a meaningful email subject is suggested. |
Email Body |
Body of the email. To define the email body, do one of the following:
Note: The Email Body Template setting (if specified) takes precedence over this setting. By default, the Email Body includes data values from the added or updated row, excluding |
Other email parameters
Expand and customize the Advanced settings, as described below.
Setting |
Description |
CC |
List of email recipients to carbon copy (CC). Click Add to add an email address or an expression using the Expression Assistant. Repeat to add additional email recipients. See Add email recipients for more information. |
BCC |
List of email recipients to blind carbon copy (BCC). Click Add to add an email address or an expression using the Expression Assistant. Repeat to add additional email recipients. See Add email recipients for more information. |
Reply To |
Email address that will receive replies to the email. Enter an email address or an expression using the Expression Assistant. See Add email recipients for more information. Defaults to |
Customize "From" name | Customize the email address displayed in the From field of the email. By default, the app creator is used (for example, [email protected] ). |
PreHeader |
Email preheader summary text that follows the subject line when viewed in an inbox. Specify text, variables, and expressions. For example:
To suppress the PreHeader, enter a single space character. Defaults to:
For example: Note: See also Built-in variables. |
Email Body Template |
Template to use for more precise control of the email body. See Use templates in a bot and the Email Body description (above). |
Attachment settings
Expand and customize the Attachment settings, as described below.
Setting |
Description |
Attachment Content Type |
Content type of the email attachment file. Valid content type values include:
Defaults to PDF which is the most often used content type for email attachments. |
Attachment Template |
Template to use for more precise control of the email attachment. See Use templates in a bot and Archive email attachments for more information. |
Attachment Name |
Name of attachment. Specify text, variables, and expressions. For example:
See Archive email attachments and How the archive attachment filename if formed for more information. |
Attachment Archive |
Attachment file archive configuration. Valid values include:
See Archive email attachments for more information. |
Attachment File Store |
File system where attachments are stored. When set to Default (the default setting), the attachment file is archived to the authentication provider file system. For example, if your authentication provider is Google, the attachment file is archived to Google Drive. If your authentication provider is Dropbox, the attachment file is archived to Dropbox. Notes:
See Archive email attachments for more information. |
Attachment Folder Path |
Folder path where attachments are saved relative to the default app folder. Specify text and expressions. For example:
In the second example, email attachment files would be stored in a separate folder, based on the month. For example: Defaults to See Archive email attachments and How the archive attachment folder name if formed for more information. |
Disable Timestamp? |
Toggle to indicate whether to append a timestamp to attachment filenames. Appending the timestamp will ensure the filenames are unique. The timestamp contains the date and time at which the attachment file was created, formatted as follows: yyyyMMdd_HHmmss_fff indicating year, month, day, hours, minutes, seconds, and milliseconds. For example:
If you disable the timestamp, you must ensure that every attachment filename is unique. Otherwise, the attachment files may be overwritten. For example, if you are archiving your attachment files to Google Drive and you disable the timestamp, only the most recent attachment file will be available. Older attachment files with the same name will have been overwritten. Disabled (timestamp is appended) by default. See Archive email attachments for more information. |
Attachment Page Orientation |
Page orientation of the attachment. Valid values include: Portrait and Landscape Note: This setting is available only if you set Attachment Content Type to PDF. |
Attachment Page Size |
Page size. Select a standard size or select Custom and enter the Attachment Page Width and Attachment Page Height in millimeters. Note: This setting is available only if you set Attachment Content Type to PDF. |
Use Custom Margins |
Toggle to indicate whether you want to specify custom margins for the attachment. If disabled, the task uses default margins. If enabled, customize the margins using the additional settings displayed, as described below. Note: This setting is available only if you set Attachment Content Type to PDF. Disabled by default. |
Other Attachments |
Other attachment files such as drawings, images, signatures, thumbnails, or files. Click Add to add other attachments to the email. Specify text or expressions. Repeat to add additional attachment files. See Add other attachments to an email for more information. |
If you enable Use Custom Margins, customize the attachment page margins using the additional settings displayed, as described below.
Setting |
Description |
Default (if applicable) |
Attachment Page Margin Top |
Top margin for the attachment in points. |
0 |
Attachment Page Margin Right |
Right margin for the attachment in points. |
0 |
Attachment Page Margin Bottom |
Bottom margin for the attachment in points. |
0 |
Attachment Page Margin Left |
Left margin for the attachment in points. |
0 |
Advanced
Expand and customize the Advanced settings, as described below.
Setting |
Description |
Inputs |
Add inputs to dynamically configure a task. For details, see Set input values dynamically in tasks.
Then, use the following expressions to access the input values from the current step: |
Add email recipients
OutgoingEmailAllowListViolations
error in Audit History, then either your team admin has restricted the recipient list for outgoing mail or sending email to external recipients is not allowed by policy, as described in Set the AppSheet Core security setting. To address this issue, contact your team administrator to adjust the restricted recipient list or contact your Workspace administrator for assistance with turning off the AppSheet Core Security setting.The following provides guidelines for adding the email recipients in To, CC, and BCC when configuring the email (described above):
-
Enter a specific email address, such as
[email protected]
.
If an email address contains special characters such as hyphen or plus, you must enclose the email address in quotes. For example:"[email protected]"
-
Use a field in a record that is being modified.
For example, when a new order is received, you can send an email to the customer who created the order. In this scenario, enter the name of the field that contains the customer's email address. For example, if theCustomerEmail
field in the order record contains the customer's email address, enter the following expression:[CustomerEmail]
-
Use a field in a record that is referenced by the record being modified.
For example, when a new order is received, you can send an email to the customer who created the order. Each order record might contain a reference to a customer record that contains the customer's email address. In this scenario, enter the name of the order record field that references the customer record followed by the name of the customer record field that contains the customer's email address. For example, if the order record field that references the customer record isCustRef
and the name of the customer record field containing the customer's email address isCustEmail
, specify the customer's email address by entering the expression:[CustRef].[CustEmail]
-
Use an entire column in another table.
For example, each time a new order is added, you can send an email to all of the people defined in another table. In this scenario, enter the name of the table followed by the field that contains the email address. For example, if you create a table calledPeopleToInform
that contains two columns,Name
andEmailAddress
, each time a new order is added, you can send email to all of the people in thePeopleToInform
table by entering the expression:PeopleToInform[EmailAddress]
-
Use selected rows in another table.
For example, each time a new order is added, you can send an email to all of the people in the sales department. In this scenario, enter the name of the table followed by the field that contains the email address, and set the department field to Sales. For example, if you create a table calledPeopleToInform
that contains three columns,Name
,EmailAddress
, andDepartment
, each time a new order is added, you can send an email to all of the people in thePeopleToInform
table who are in theSales
department by entering the expression:SELECT(PeopleToInform[EmailAddress], ([Department] = "Sales"), TRUE)
Note: While the app is in test mode (that is, you have not run a deployment check and deployed the app), any messages sent will be sent to the app creator only. To confirm the list of email recipients that will be included in To, CC, and BCC, check the Audit History, as described in How do I determine whether an email was delivered?
Examples of sending an email from an automation
The following provide examples of sending an email from an automation.
Send email when a row is updated to have a specific column value
You can create a workflow rule that sends an email when a row is updated to have a specific column value. For example, you might send an email when the Status
column in the ServiceRequests
row is updated to contain the value Active
.
AND(
("Active" = [_THISROW_AFTER].[Status]),
([_THISROW_AFTER].[Status] <> [_THISROW_BEFORE].[Status])
)
In this expression, note the use of [_THISROW_BEFORE]
and [_THISROW_AFTER]
. These are system-provided references that refer to the state of the row before and after the change was made, respectively. This is really useful in order to check if the value of a field changed from one value to another.
Because [_THISROW_BEFORE]
and [_THISROW_AFTER]
are references, you use a dereference expression to access the value of a specific column in the referenced row.
Send an email only after adding a parent record and all of its child records
When you add a parent record along with one or more child records, AppSheet first adds the parent record, then each of the child records. This can make it difficult to trigger an automation event only after all of the child records have been added.
You can can use the following technique to ensure that all parent and child records are added before the event is triggered. This technique uses the Form Saved
event to trigger a data-change action which triggers the event only after the child records have been added.
Do this as follows:
-
The child table must contain a
Ref
field to the parent table. Enable theIs a part of?
property of theRef
field. This makes it possible to add child records when the parent record is added. -
Add a
Text
field to the parent table. Call the field Status and set itsInitial value
property to""
(blank). TheStatus
column controls whether the data change event triggers. -
Create a data-change action for the parent table which sets the
Status
column's value to"Run"
. -
Create a second data-change action for the parent table which sets the
Status
column's value to""
(blank). -
Create a composite action for the parent table that invokes the two data-change actions above. This composite action invokes the first data-change action to set the
Status
column's value to"Run"
, and the second data-change action to set theStatus
column's value to blank. These two data changes will be sent to the server as separate updates. The first update triggers the automation event, while the second update prevents further updates from triggering the automation event. -
Go to the UX > Views tab. Click Show system views. Select the form for the parent table. Expand Behavior. Find Event Actions and set its
Form Saved
property to the compositive action created in the previous step. -
Set your data change event to Updates only. Set its
Condition
property to:[Status] = "Run"
Prevent app creators from adding email attachments in automations
Prevent app creators from adding email attachments in automations by using the "Restrict Automation Email Attachments" policy, as described below. For more information, see Define governance policies.
To app creators from adding attachments to emails sent from automations:
- Select My account > Policies.
- Click + Account Policy or + Team Policy to add an account or team policy, respectively.
- Select Restrict Automation Email Attachments from the Policy Template drop-down.
- Click Next.
- The policy is preconfigured for you. You can modify any of the field values. See Add a predefined policy for a description of each field.
Important: If you modify the Condition field, ensure that you retain the functionality defined below:
AND(ISBLANK([AttachmentTemplate]), ISBLANK([OtherAttachmentList]))
- Click Save.