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
Step 1
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
Step 2
Connect to Exchange Online (EXO)
Import-Module ExchangeOnlineManagement
Connect-ExchangeOnline
Step 3
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.
-Category <String>
- 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
Exporting data
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
Now that you have your total number of received emails, you can do the same for sent emails by changing the -Category to TopMailSender for example
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
Source: Microsoft
#EdTech Network Manager, experienced in Microsoft 365, Server 2019, Intune, SCCM and anything inbetween.
Get-MailTrafficSummaryReport doesn’t return any data after 6th Jun 23.
Any date before this (within the 90day window) returns data no problem.
Get-MailTrafficSummaryReport -Category TopMailSender -StartDate 04/06/2023 -EndDate 05/06/2023 | Select C1,C2
Data returned
Get-MailTrafficSummaryReport -Category TopMailSender -StartDate 07/06/2023 -EndDate 08/06/2023 | Select C1,C2
No data, no error just returns to the prompt
Any one else seeing this odd problem?
I’ve just tried running this report:
Microsoft 365 Defender / Reports / Email & Collaboration / Top senders and recipients
If I use dates before 6th jun23 it shows a graph and returns data
Any date after the 6th Jun 23 empty graph and no data
When I get chance I’ll check to see if I see the same results.
Has anything changed on your tenant?
Nothing that I’m aware of.
That PowerShell has been working great since we migrated from gmail to 365 at the start of this year.
I would be really interested in your results
Thanks
Ian
Hi Ian, I’ve had a look at mine and getting similar results. We do get SOME data back but only showing 1 or two emails per mailbox (should be alot more!) Not sure if this is you or not, but if not someone on reddit has the same issue. https://www.reddit.com/r/exchangeserver/comments/1496in1/the_getmailtrafficsummaryreport_cmdlet_is_stopped/
I did read they planned on retiring this report on June 14th but seemingly scrapped that idea, could be linked but not sure!
Hi Liam,
Thanks for checking I’m glad its not just me or my companies tenant. I also don’t think its just UK as i’ve had confirmation from someone in India they are seeing the same.
Here are my results as of this morning (19/06/23)
04/06/23 Data returned (Figures as expected)
05/06/23 Data Returned (Figures as expected)
06/06/23 Data Returned (Only one entry everything else missing )
07/06/23 NO Data Returned
08/06/23 NO Data Returned
09/06/23 NO Data Returned
10/06/23 NO Data Returned
11/06/23 NO Data Returned
12/06/23 NO Data Returned
13/06/23 NO Data Returned
14/06/23 NO Data Returned
15/06/23 NO Data Returned
16/06/23 Data Returned (only 5 entries all the rest missing This is a working day so there would be lots more!)
17/06/23 Data Returned (only 5 entries BUT they are identical results inc counts to 16/06/23! but I’m not sure if its to soon to run for 17th?)
Looks like that person on reddit is who I’ve been talking to here
https://o365reports.com/2020/08/12/export-office-365-mail-traffic-report-with-powershell/
Still nothing except a daily message from MS:
We are engaging with our next level team investigation still ongoing, once we get, we will connect with you.
Still, we haven’t proper update, once we had we will connect with you.
We are appreciating your patience.
Regards,
Sushma
Microsoft 365 Support Engineer
Can’t say I’m filled with confidence.
I’ve just had an email from MS saying the issue is now fixed. I have not had chance to check myself yet.
I am now getting results from the command however after spot checking a couple of users the results are not correct!
I also tried adding ‘-Domain ALL’ which increased some results and oddly decreased others!?
I have reported this back to MS.
MS are telling me I have to raise another case over the incorrect results!
How strange! I’ve not had chance to check myself but there’s definitely a bug somewhere! Please keep us informed when MS get back to you!
Hi Liam,
I have a list of mailboxes which I need to get traffic reports on, is there a script I can run which will import my user list and then export out a traffic report based only on my users?
I don’t have one I’m afraid but I’m sure it would be possible. The quickest way I could think of is creating an Excel file with the users you want to track and use VLOOKUP to the CSV file containing all users. You’d then just run the report and drop the new CSV file into the same location and it should work!
Final response from Microsoft support it will not work for intra-org emails only external emails!
If you are trying to verify the sending mail data reports for the External senders, we will get the same results in Both Outlook applications and PowerShell outputs.
If you are trying to match the mail sending reports for Internal users will not get the same results, it’s still on the features on yet to developed from our Product team.
Currently the feature not available for users.
Please can you confirm with the customer if the email was sent within the organization? basically were they intra-org sent emails.
if that is the case, then the numbers won’t add up.
This feature still not released from Microsoft end. There is no ETA.