Introduction: Hello Guys, “Welcome back” Today, i am here with another one new great article. In this article I explained how to check email queue in SQL Server.
Join our Channel on Whtsapp and Telagram for All Updates
Check Email Queue in the Log Tables
Implementation: In SQL Server, the information or status of the email that are sending is in the queue in the msdb.dbo.sysmail_unsentitems table until not sent.
The below SQL query will be use to check the the email that are in Queue in SQL Server.
SELECT * FROM msdb.dbo.sysmail_unsentitems
If you are unable to find the email in the above table, then there will be two cases to find the status of the sending email. The name of the two cases is as follows:
1. Email has been sent
2. Email has failed
Case 1: Email has been sent
The emails that are already sent to the mentioned email address without any are stored in the msdb.dbo.sysmail_sentitems table. The below SQL query will be use to check the email that are sent without any issue:
SELECT * FROM msdb.dbo.sysmail_sentitems
Case 2: Email has failed
In the second case the Emails that are failed to send or not send yet, are stored in the msdb.dbo.sysmail_faileditems table. The below SQL query will be use to check the email that are failed to send or not send yet
SELECT * FROM msdb.dbo.sysmail_faileditems
The Error or Error Messages are not stored in the above motioned table. The details of the Error or Error Messages will be stored or present in the msdb.dbo.sysmail_event_log table. The following SQL Query will be use to find the details or error message of sending failed emails.
SELECT mailitem_id
,[subject]
,[last_mod_date]
,(SELECT TOP 1 [description]
FROM msdb.dbo.sysmail_event_log
WHERE mailitem_id logs.mailitem_id
ORDER BY log_date DESC) [description]
FROM msdb.dbo.sysmail_faileditems logs
Conclusion: In above code, I have been explained explained how to check email queue in SQL Server. This code is very helpful for every developer. Bye and take care of you Developers. We will come back shortly with the new article.
Regards
Using Asp.net
No comments:
Post a Comment