Introduction
This article describes how to adjust an existing task to notify the task administrator that a task instance has generated failed emails.
Note: This procedure is only for BPA Platform installations that make use of a SQL Server store. Required data cannot be extracted from an internal store.
The BPA Platform server contains a data store where information, such as configured tasks, are stored.
Two store types are available:
| ► | Microsoft SQL Server Store — Holds the Store in a SQL database. This can be in a local or remote SQL Server installation. (RECOMMENDED) |
| ► | Internal Store — Holds the Store locally on the installed computer's hard drive. Typically, this is c:\iwdb. |
| Internal Store | Microsoft® SQL Server Store | |
|---|---|---|
| Requirements | Available space on disk only |
Microsoft® SQL Server™ 2014 or higher |
| Speed | Very fast, but can slow as usage increases | Fast and scalable, even on busy servers |
| Reliability | Reliable, but corruption can occur in rare circumstances | Very reliable, relies on SQL Server Integrity |
|
Maintenance |
Maintenance takes time to run due to de-fragmentation | Maintenance is very quick as de-fragmentation is performed by the database administrator |
| Backup | Backup must be made by backing up the Backup sub-folder of the BPA Platform Internal Store | Backup is left to the database administrator who is maintaining the SQL Server backup |
Scenario
You have a task that sends emails to multiple contacts, either different per task run or during each task run-time. Either yourself or the task administrator (owner) wants to be notified each time an email attempt fails.
Required Tools
| ► | Database Query (either ODBC or OLEDB) — This step queries the BPA Platform store for the email addresses that the task failed to deliver to. |
| ► | Format as HTML — The results from the query are saved to an HTML report as a table . |
| ► | Send Email (SMTP) — The report is emailed to the task administrator. |
Prerequisites
A global connection to the BPA Platform store is required. You can do this in your preferred Database Query tool. Typically, the BPA Platform store is held in the BPAPlatform database, however, a different database name can be entered at configuration time. To find the name of your store, do the following:
- Launch the Configurator
You use the Configurator to install third-party software that may be required by available tools. Connection to required agents are also configured here. Note that you can only launch the Configurator if logged into the machine with Administrator rights.. - Expand the Server > Store > Configuration nodes.
- Enable Change store configuration and click Next.
- The current store name is under Database. Click Close then No to not save any changes. Avoid changing the store database name as events and tasks in the original store may not be available to you.
Logging and Notifying Failed Emails
The required tools are added after the Send Email (SMTP) step in your task. Do the following:
- Open the relevant task.
- Open the existing Send Email (SMTP) step and go to the Options tab.
- Change If an error occurs to Continue.
- Click OK to save and close the Send Email (SMTP) step.
- Add a Database Query step.
- In the General tab, choose the global connection you created in Prerequisites.
- In the Query tab, expand the EventLog node.
- Add the following columns to the Columns pane:
EventSource
TaskID
EventCategory
EventDesc
EventTime - Add Criteria for the following (these are all linked by
AND):EventSource
=The original Send Email (SMTP) step's name
How Do I Do This?- Drag the EventSource column to the Criteria pane.
- Select a criteria of equals [C].
- From the Task Browser's Environment tab, change Scope to be Task.
- Expand Steps > <the_original_Send Email (SMTP)_step>.
- Drag the Name property to the available criteria box for EventSource.
TaskID
=This task's ID
How Do I Do This?- Drag the TaskID column to the Criteria pane.
- Select a criteria of equals [I].
- From the Task Browser's Environment tab, change Scope to be Task.
- Drag the TaskID property to the available criteria box for TaskID.
EventTime
=The start time of the original Send Email (SMTP) step during the task run
How Do I Do This?- Drag the EventTime column to the Criteria pane.
- Select a criteria of equals [D].
- From the Task Browser's Environment tab, change Scope to be Task.
- Expand Steps > <the_original_Send Email (SMTP)_step>.
- Drag the Started property to the available criteria box for EventTime.
- Add the Sorting pane to the view (
). - Add EventTime to the sorting pane.
We need to add a few more things to our SQL statement that, at the time of writing, aren't handled by the interface.
- Click
to change into free-type mode. Accept the warning. - Add an additional
ANDcriteria to theWHEREstatement:EventLog.EventDesc LIKE 'Sending%@%'. This searches for event descriptions that start with "Sending" and have an@symbol somewhere in the description. - Change the
ORDER BYstatement to be descending (DESC).
The final SQL statement should look like:
SELECTEventLog.EventSourceASEventSource EventLog.TaskIDASTaskID EventLog.EventCategoryASEventCategory EventLog.EventDescASEventDesc EventLog.EventTimeASEventTimeFROMEventLogWHEREEventLog.EventSource='{=Steps("<Send Email (SMTP) step name>").Name}'ANDEventLog.TaskID={=Task.TaskID}ANDEventLog.EventTime={=Steps("<Send Email (SMTP) step name>").Started}ANDEventLog.EventDescLIKE'Sending%@%'ORDER BYEventLog.EventTimeDESCClick OK to save and close the Database Query step.
- Add a Decision step which uses a decision branch to check for a failed Send Email (SMTP) step. If none is found, the remaining task steps do not fire.
How Do I Do This?- Add a new decision branch.
- In the General tab, Name the branch and choose the new Database Query step (step 5) as the To step.
- In the Script tab, drag the FailCount property for the original Send Email (SMTP) step to the available script box.
- Add
>0to the end of the line so the script reads:Steps("<Send Email (SMTP) step name>").FailCount>0.
Click OK to save and close the Decision step.
- Add a Format as HTML step which consumes the recordset from the Database Query step from step 5 and presents the data in an HTML table.
How Do I Do This?- In the General tab, enable Use a Recordset.
- From the Input Recordset drop-down, select the new Database Query step from step 5.
- Go to the Formatting tab and click Design.
- From the Task Browser's Environment tab, change Scope to be This Step.
- Expand FormatData > Recordset and drag each column in turn to the HTML Table Designer.
Click the image to view full size.
- Adjust the column attributes as required — for more information, see How to Add a Format as HTML Task Step.
- Click OK to save the HTML table.
- If required, add further HTML elements to the document else click OK to save and close the Format as HTML step.
- Finally, add another Send Email (SMTP) step which emails the output from the Format as HTML step to the task administrator.
How Do I Do This?- In the General tab, enable Read documents from a source.
- From the Document Source drop-down, select the Format as HTML step.
- Go to the Connection tab and choose the SMTP server to send this email through.
- In the Main tab, add relevant From and To email addresses and a Subject.
- In the Message Contents pane, enable Document Output.
- Click OK to save and close the Send Email (SMTP) step.
- Link the new steps as follows:

How Do I Do This?- Steps are linked left-to-right in the order of the process flow. Click the first step to show the step controls. Click and hold
then draw the connection to its succeeding step. - Repeat for all steps. Note that the Decision step is automatically linked to its successor.
- Steps are linked left-to-right in the order of the process flow. Click the first step to show the step controls. Click and hold
That's all the required configuration. It may be an idea to run a quick test of your completed task to ensure the correct details are sent for a failed email attempt.
Article originally published 24 March 2016 — Article updated 22 October 2019