Advertisement
crexin

CRM Email Router - Detect Emails Taking Longer than 5 min

Dec 18th, 2017
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.75 KB | None | 0 0
  1. /*
  2. Show Emails from last 1 days and time to send in min where time to send > 5 min.
  3. Useful to know if emails may be stuck in a pending send status
  4. */
  5.  
  6. SELECT Subject,
  7. CASE
  8. WHEN StatusCode =3 THEN 'Sent'
  9. END AS 'Status Name'
  10. ,DeliveryAttempts,CreatedOn,SentOn,DateDiff("mi",CreatedOn,SentOn) AS 'TimeToSend(min)'
  11. FROM Email (NOLOCK)
  12. WHERE DirectionCode = 1
  13. --AND SentOn != null
  14. --uncomment next line to restrict to only those that take more than 10 min to send
  15. --AND DateDiff("mi",CreatedOn,SentOn) > 10
  16. AND StatusCode = 3
  17. -- Only show emails from last day
  18. AND CAST(DateDiff("day",CreatedOn,GetDate()) AS INT) <= 1
  19. --Return emails that took longer than 5 min to send
  20. AND CAST(DateDiff("mi",CreatedOn,SentOn) AS INT) > 5
  21. ORDER BY Email.CreatedOn DESC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement