SQL agent job for long running queries
The way I usually go about this is to use the procedure sp_WhoIsActive, and log that to a table. This way I don't have to worry about about the result of the procedure being right, cause I'm sure it is.

There are some great articles on the Brent Ozar website about it.

Brent Ozar logging sp_WhoIsActive

Brent Ozar Monitoring activity

Afterwards you can do whatever you want with that data. 
You can transfer data from the logging table to the Dxxx.dbo.TDBMSG table, or send mails directly from the WhoIsActive table.