Showing posts with label email. Show all posts
Showing posts with label email. Show all posts

Monday, September 22, 2014

Checking Email log in SQL Server

--SENT MESSAGES LOG
SELECT TOP 20 *
FROM [msdb].[dbo].[sysmail_sentitems]
ORDER BY [send_request_date] DESC

--FAILED MESSAGES LOG
SELECT TOP 20 *
FROM [msdb].[dbo].[sysmail_faileditems]
ORDER BY [send_request_date] DESC

--ALL MESSAGES – REGARDLESS OF STATUS
SELECT TOP 20 *
FROM [msdb].[dbo].[sysmail_allitems]
ORDER BY [send_request_date] DESC

Friday, August 23, 2013

Send an Alert thru email on number of User Connections

IF (SELECT cntr_value FROM sys.dm_os_performance_counters WHERE counter_name='User Connections')>0
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'MyProfile',
@recipients = 'Mymai@MyMailcorp.com',
--@body = @bodyText,
@body_format = 'TEXT',
@subject = 'Testing Email' ;