The Below Query will help you to find the Real-time Incoming and Outgoing Emails from CRM. Execute the Query on Respective CRM Organization_MSCRM Database.

Specify the No of days required in datediff("Day",createdon,getdate()) <= 1

SELECT

statuscode, statecode, COUNT(1) as 'Email Count',

CASE

WHEN StatusCode=1 then 'Draft'

WHEN StatusCode=2 then 'Completed'

WHEN StatusCode=3 then 'Sent'

WHEN StatusCode=4 then 'Received'

WHEN StatusCode=5 then 'Canceled'

WHEN StatusCode=6 then 'PENDING SEND***'

WHEN StatusCode=7 then 'Sending***'

WHEN StatusCode=8 then 'Failed***'

END as 'Status Name'

FROM

Email(nolock)

WHERE

datediff("Day",createdon,getdate()) <= 1

GROUP BY

statuscode, statecode

ORDER BY

statuscode, statecode

Results: