SQL examples: Retrieving the user interface status and progress
1 To retrieve the count of processed records, open an ADO connection to the SendEmailHistory table and run the following query:
SELECT SUM(SuccessfulEmailCount)
FROM SendEmailHistory
WHERE Project=<project>
AND Job=<job>
2 To retrieve the status, first ensure that the job is completely setup and the status is set to Incomplete. If the job is not setup, you can check for emails that are being sent with the following query.
SELECT ScheduledTaskId
FROM SendEmailHistory
WHERE Project=<project>
AND Job=<job>
AND BatchStatus=Active
3 Next, check if a task is scheduled by using the following query. When a record is returned, and the ScheduledTaskStatus is Completed, set the status to Schedule completed. When the ScheduledTaskStatus is Waiting, set the status to Scheduled for <datetime including time zone indicator>.
SELECT ScheduledTaskStatus, NextDueTime
FROM ScheduledTasks
WHERE Project=<project>
AND Job=<job> (requires a join to SendEmailTasks table)
ORDER BY NextDueTime
If a record is not returned, there are no tasks in progress and no scheduled tasks. In this case, set the status to Ready.
See also