USE msdb;
GO
DECLARE @age INT = 5; -- age in minutes
DECLARE @cutoff DATETIME = DATEADD(MINUTE, -@age, CURRENT_TIMESTAMP);
SELECT recipients, subject, sent_status, send_request_date
FROM dbo.sysmail_faileditems
WHERE send_request_date >= @cutoff
ORDER BY send_request_date;
/*
In fact, there are some items that appear in the log
but not in failed items for some reason, and failed
items doesn't describe the problem anyway. So as @Oleg
added I would also run this query:
*/
SELECT mi.recipients, mi.subject, l.description, l.log_date
FROM dbo.sysmail_log AS l
LEFT OUTER JOIN dbo.sysmail_mailitems AS mi
ON l.mailitem_id = mi.mailitem_id
WHERE l.log_date >= @cutoff
AND l.event_type > 1
ORDER BY l.log_date;
sp_CONFIGURE 'show advanced', 1
GO
RECONFIGURE
GO
sp_CONFIGURE 'Database Mail XPs', 1
GO
RECONFIGURE
GO
select * from msdb.dbo.sysmail_faileditems
select * from msdb.dbo.sysmail_log
假设您在最后 5 分钟内想要:
抱歉,需要毒化 SMTP 服务器以验证我的原始答案是否足够。:-)
下列的