Hi, @AhmadHassan-1209
explain: email address sent or received and he attach file or not
Get-Messagetrackinglog can't show whether an attachment is contained in the email.
As a workaround, you may check it with the "totalbytes" parameter, which contains the total size of the email, including attachments.
I suppose that you may use the following commands via EMS to achieve your goal.
internal message sent:
get-messagetrackinglog -resultsize unlimited -start "01/20/2021" -end "01/26/2021" | where-object {$_.eventid -like "send" -and $_.sender -like "*@domain-a.com"} | select-object timestamp,sender,@{l="Recipients";e={$_.Recipients -join " "}},messagesubject,totalbytes | export-csv C:\send_internal.csv
external message sent:
get-messagetrackinglog -resultsize unlimited -start "01/20/2021" -end "01/26/2021" | where-object {$_.eventid -like "sendexternal" -and $_.sender -like "*@domain-a.com"} | select-object timestamp,sender,@{l="Recipients";e={$_.Recipients -join " "}},messagesubject,totalbytes | export-csv C:\send_external.csv
internal message received:
get-messagetrackinglog -resultsize unlimited -start "01/20/2021" -end "01/26/2021" | where-object {$_.eventid -like "deliver" -and $_.recipients -like "*@domain-a.com" -and $_.sender -like "*@domain-a.com"} | select-object timestamp,sender,@{l="Recipients";e={$_.Recipients -join " "}},messagesubject,totalbytes | export-csv C:\receive_internal.csv
external message received:
get-messagetrackinglog -resultsize unlimited -start "01/20/2021" -end "01/26/2021" | where-object {$_.eventid -like "deliver" -and $_.recipients -like "*@domain-a.com"-and $_.sender -notlike "*@domain-a.com"} | select-object timestamp,sender,@{l="Recipients";e={$_.Recipients -join " "}},messagesubject,totalbytes | export-csv C:\receive_external.csv
You may also combine the commands to a powershell file if you would like to.
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.