Send email notifications

Many workflows require that an email be sent when a feature or record is created and updated. The Send Emails tool can be used to configure email messages that can be sent based on attribute values and a schedule of your choosing. Note that the tool only generates the configuration; an additional script (provided) must be run to actually generate and send the emails.

Configuring and executing this script requires the ArcGIS API for Python (Installed with ArcGIS Pro).

To configure email notifications for new and updated reports, complete the following steps:

  1. Download and extract the ServiceFunctions toolbox. The tools in this toolbox create and update a configuration file that can then serve as input for a scheduled script (provided) which will perform the configured actions.
  2. Open the toolbox in ArcGIS Pro 2.x and, if you've never used the toolbox before, run the Define Connection Settings tool to establish a connection between the toolbox and the ArcGIS Enterprise portal or ArcGIS Online organization containing the layers which will be used to trigger and generate the emails.
  3. Open the Send Emails tool.
  4. If the tool has not been run previously, start by specifying the connection information for your SMTP server in the General Email Settings section of the tool by providing the following values:
    • SMTP Server—URL and port (if needed) of the SMTP server used for sending emails. If unsure of the SMTP server connection details, contact your IT for clarification.
    • SMTP Username—The username required to authenticate to the SMTP server. This is not required if authenticating through a port.
    • SMTP Password—The password required to authenticate to the SMTP server. This is not required if authenticating through a port.
    • From Address—The address from which the emails should be sent.
    • Reply Address—The address that should be used for any replies to the email message.
    • Use TLS—Enable or disable TLS.
    • Email Substitutions—Swap out one piece of text for another in the outgoing email subject or body. Anywhere a value in the Find column is found in the email subject or body, it will be replaced with the corresponding value from the Replace column. If the value in the Replace column is a field in the layer, the Find value will be replaced with the value in that field in the triggering feature. For example, to add the ID of a feature from the REQUESTID field to the email subject, include a piece of text such as {ID} in the configured Email Subject, and add {ID} to the Find column and REQUESTID to the Replace column in this parameter. All specified substitutions are applied to all emails configured for all layers so, while the Find values can be any piece of text, it's suggested that you use something that is clearly variable-like and unlikely to appear elsewhere in the messages in a literal form.
    Keep in mind that deleting or changing these settings will impact all the emails for all the layers configured with this tool.
  5. Choose the feature layer or table layer that will trigger an email notification by either choosing a layer from the active map, or by browsing to your hosted content and choosing a feature layer or table layer.
  6. All existing email settings for the layer will load, and can be edited by updating the parameter values for each configuration. To delete a single email configuration, click the x next to the configuration. To delete all the email configurations for the layer, check the Delete all existing email configurations for this layer checkbox. Execute the tool to save your changes.
  7. Browse to the path of an HTML template for the body of the email. To add attributes from the triggering feature to the email, use unique string keys in the places where the values should appear in the HTML and reference these strings in the Find column of the Substitutions section of the General Email Settings along with the name of the field that contains the value to be substituted for the string key in the Replace column.
  8. Choose the moderation list to use to process the features in the selected layer.
  9. Optionally, provide an SQL query to only trigger an email from specific features. If no query is provided, all features will trigger emails every time the script is run, so you most likely want to use this query along with the Field to Update and Sent Value parameters to ensure that the same emails isn't sent repeatedly for the same feature.
  10. Provide either the email address of the recipient, or the name of a field in the layer that contains the address of the recipient.
  11. Provide the subject for the email message. Like the email body provided in the HTML document, this text can contain string keys that will be swapped out for attribute values based on the Find and Replace values defined in the Email Substitutions list in the General Email Settings section.
  12. Choose a Field to Update when this email has been sent for each feature. Use the Sent Value parameter to specify the value that should be written to this field indicating that the email has been sent. This field and value can be used in the previously-described SQL query to prevent duplicate emails from being sent.
  13. Configure additional emails to be sent for the currently selected layer by clicking the + button. Emails will be sent in the order they are configured.
  14. To test the configuration, run the script that accompanies the toolbox. If errors occur, they will be written to a log file that will be created in the same directory as the script. The ServiceFunctions toolbox, script, and the servicefunctions.json file created by the toolbox must all remain in the same directory.

Set up Task Scheduler

Use Windows Task Scheduler to schedule the script to send email notifications.

This is only necessary if has not been previously scheduled. All the tools in this toolbox share a common configuration file and execution script so only one scheduled task is required to automate running all the associated processes.

  1. Open the Task Scheduler on the computer that is hosting the scripts.
  2. Click Action > Create Task and name your task.
  3. Click the Action tab and click New.
  4. Set Action to Start a Program.
  5. Browse to the location of your Python 3 installation (for example, <default directory>\C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe).
  6. In the Add arguments text box, type the name of the script (
  7. In the Start in text box, type the path to the folder where your script is and click OK.
  8. Click the Trigger tab, click New, and set a schedule for your task.
  9. Click OK. When the trigger occurs, the scripts will begin scanning the configured layers and, for each one, processing (in order) configurations for generating identifiers, enriching reports, moderating reports, and sending emails.