NOTE: This article has been updated and moved to the Codeless Platforms Documentation Portal.
If you are seeing this message and have not been redirected, click: How to Log Failed Emails from a Send Email (SMTP) Step.
<!–
If you have a task that sends emails to multiple contacts then you may wish to receive a notification if an email attempt fails to one or more addresses. This is achieved by adding an additional number of steps to your task to act as an error trap. These steps will appear after the initial Send Email (SMTP) step as follows:
- Decision – This step uses the property FailCount and will trigger the notification when an error is flagged within the Send Email (SMTP) step.
- Database Query – This step queries the TaskCentre database store to locate the email addresses that the task failed to deliver to.
- Format as HTML – The information obtained by the database query is presented in a table. The table will include details such as the task ID, the time of the event and the email addresses at fault.
- Send Email (SMTP) – A second email step is introduced which notifies the task administrator and will include the formatted table of events.
Prerequisites
- Within TaskCentre, create a global ODBC or OLEDB connection to TCDatabase, i.e. the TaskCentre store on SQL Server. This will allow you to query the TaskCentre event logs.
Task Design
- Within the Send Email (SMTP) step enter the Options tab and select Continue if an error occurs. This will ensure the step will continue processing emails and will allow for failed deliveries to be logged.
- Add a Decision step to the task which uses the following script to enable the error trapping; where Send Email (SMTP) is the name of your email step sending the initial notifications.
Steps("Send Email (SMTP)").FailCount>0
- Add a Database Query ODBC or OLEDB step to the task. Set it to use the connection to the TaskCentre store then add a SQL select as required below; under WHERE be sure to enter your own task and step ID.
SELECT EventLog.StepID AS StepID, EventLog.TaskID AS TaskID, EventLog.EventCategory AS EventCategory, EventLog.EventDesc AS EventDesc, EventLog.EventTime AS EventTime FROM EventLog WHERE EventLog.StepID = 206 and EventLog.TaskID = 61 and EventLog.EventTime >= DATEADD(day, DATEDIFF(day, 0, GETDATE()), 0) and EventLog.EventDesc like 'Sending%@%' ORDER BY EventLog.EventTime Desc
This script will return any failed emails for the task.
- Add a Format as HTML step to the task which uses a table to present the output from the Database Query step.
- Finally, create another Send Email (SMTP) step and make sure the HTML document from the Format as HTML step is consumed.
A notification can now be delivered to a recipient that provides a list of emails that failed to send.
–>