In this tutorial i will explain how to use PowerShell to create a report to identify the number of emails sent and received per user in Microsoft 365 Exchange online. Microsoft does offer usage reports in the admin centre, however they do not necessarily show the indivdual number of emails sent/received per mailbox for a set period of time, the data can only currently be viewed for the last 30, 7 or 90 days, with no specific dates. Usage – Microsoft 365 admin center
Install the latest version of EXO module for PowerShell, open up an elevated PowerShell window and type the following cmdlet
Install-Module –Name ExchangeOnlineManagement -Force
Connect to Exchange Online (EXO)
Now we can use the Get-MailboxTrafficSummaryReport cmdlet to identify the number of emails sent and received by mailboxes in your organisation. Use the -Category parameter to choose sent or received.
- TopMailRecipient – Number of received emails
- TopMailSender – Number of sent emails
To run the report, you can use the following, remember to change the date range to suit your requirements (MM-DD-YYY Format)
Get-MailTrafficSummaryReport -Category TopMailRecipient -StartDate 09/01/2022 -EndDate 09/30/2022 | Select C1,C2
This will return the number of emails received between the date range on all mailboxes in your tenant, in descending order. C1 & C2 are the cmdlet headers, C1 is the recipient or sender and C2 the quantity of email messages.
For larger organisations you may wish to limit the results to the “top 10” or similar. To do this you can use the -PageSize parameter and chose the number of results you wish to show, e.g 10
Get-MailTrafficSummaryReport -Category TopMailRecipient -StartDate 09/01/2022 -EndDate 09/30/2022 -Pagesize 10 | Select C1,C2
To export the data to CSV you can simply add the Export-CSV cmdlet to export the results to a csv file. simply add Export-Csv -Path c:\pathto\yourfolder\recievedemails.csv (note: the folder must exist)
Get-MailTrafficSummaryReport -Category TopMailRecipient -StartDate 09/01/2022 -EndDate 09/30/2022 -Pagesize 10 | Select C1,C2 | Export-Csv -Path c:\pathto\yourfolder\recievedemails.csv
Get-MailTrafficSummaryReport -Category TopMailSender -StartDate 09/01/2022 -EndDate 09/30/2022 -Pagesize 10 | Select C1,C2 | Export-Csv -Path c:\pathto\yourfolder\sentemails.csv
#EdTech Network Manager, experienced in Microsoft 365, Server 2019, Intune, SCCM and anything inbetween.