Extract All Email Addresses from Microsoft 365 Tenant


We have a client that is looking to gather all sent to and received from email addresses (not internal user accts) across their Microsoft 365 tenant. The idea being that they want to create a mailing list from all external parties that they have had previous contact with.

I have found a way to extract all of the email addresses for an individual account using Excel as well as software. However, with both of these options, you have to login to each account individually which would make this very time consuming. I am wondering if anyone knows of a way to accomplish this using PowerShell and exporting the results to a .csv? I realize it’s a longshot, but I’m about out of ideas.

Thanks in advance!

Hello jsprague48,

One of the options would be to use Get-MessageTrace (message data for the last 10 days) and Start-HistoricalSearch
and Get-HistoricalSearch cmdlets ( data older than 10 days).

Hope that helps.