USE [NoSpamProxyAddressSynchronization] 

SELECT Sent, Name, a.Size, MimeType, ma.Address, Subject, MessageId, Status, SCL, RejectReason, me.RuleName
FROM [MessageTracking].[Attachment] a 
JOIN MessageTracking.MessageTrackEntry me on a.MessageTrackId = me.Id  
JOIN MessageTracking.MessageAddress ma on a.MessageTrackId = ma.MessageTrackId
WHERE me.WasReceivedFromRelayServer = 0 -- 0 Inbound, 1 = Outbound  
AND me.Sent > DATEADD(d, -30, getdate()) -- Last xx days 
AND (MimeType = 'text/plain' OR MimeType = 'text/richtext' OR MimeType = 'text/oleobject-richtext')
AND (Name LIKE '%.doc' OR Name LIKE '%.docx')
AND ma.AddressType = 2
ORDER BY me.Sent DESC