What are the Database Mail sent from SQL Server - Between two date
DECLARE @StartDate DATETIME,
@EndDate DATETIME
SELECT @StartDate = '2011-02-01',
@EndDate = '2011-02-08 23:59:59'
SELECT
A.Name [Mail Account Name],
A.Display_Name [Mail Account Display Name],
P.Name [Mail Profile Name],
A.EMail_Address [From Mail ID],
SI.Recipients [To Mail ID],
SI.Copy_Recipients [CC Mail ID],
SI.Blind_Copy_Recipients [BCC Mail ID],
SI.[Subject] [Subject],
SI.Body [Body],
SI.Send_Request_Date [Request Date],
SI.Sent_Date [Sent Date],
SI.Sent_Status [Mail Status]
FROM MSDB.dbo.sysmail_sentitems SI JOIN MSDB.dbo.sysmail_profile p
ON (SI.Profile_Id = P.Profile_Id)
JOIN MSDB.dbo.sysmail_account A
ON (A.Account_ID =SI.Sent_Account_ID)
WHERE SI.Sent_Date BETWEEN @StartDate AND @EndDate
ORDER BY SI.sent_date DESC
GO
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment