List of emails recevied and sent from domain

AHMAD HASSAN 256 Reputation points
2021-01-21T10:15:50.68+00:00

Hello,

I need SP or anything to get all email received and send from mydomain.com with period date, explain: email address sent or received and he attach file or not
Like: all email "received or send" from mydomain.com in date 01/12/2020 to 31/12/2020 and export to excel file. separated (Internal and External)

I try some PS but return with error, also try PS found in this article but return with error

https://social.msdn.microsoft.com/Forums/en-US/38384127-53db-4859-b0f5-f377b8e275fc/get-total-number-of-sent-emails-for-internal-and-external-addresses?forum=exchange2010

Thanks for your support

NB: Exchange server 2016 CU 19 on-prem

Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,503 questions
0 comments No comments
{count} votes

Accepted answer
  1. Kael Yao-MSFT 37,676 Reputation points Microsoft Vendor
    2021-01-25T08:36:39.727+00:00

    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.


1 additional answer

Sort by: Most helpful
  1. AHMAD HASSAN 256 Reputation points
    2021-01-21T12:19:30.157+00:00

    I try this PS and he is good but can some one help and show me how modify the date to start and end period because he is return one day "yesterday"

    https://gallery.technet.microsoft.com/office/Exchange-20102013-Mailbox-e45f4af6#content

    0 comments No comments