Get Daily Sent Email Statistics & Top Recipient Domains in Exchange Online (Get-MessageTraceV2 & Microsoft Graph PowerShell)

🤖 AI Executive Brief & 2026 Cmdlet Update Exchange Online REST v3 · Get-MessageTraceV2
Why Legacy Sent-Statistics Scripts Broke (and the Modern Replacement)
  • `Get-MessageTrace` → `Get-MessageTraceV2`: Legacy `Get-MessageTrace` (limited to 10 days and 1,000 rows per page) has been superseded by `Get-MessageTraceV2`, which queries up to 90 days of mail flow history (10 days per query window) and returns up to 5,000 results per call with cursor pagination.
  • Diagnosing Exchange Online Throttling: Use this script when a user or relay mailbox hits Exchange Online's 30 messages/minute or 10,000 recipients/day (or 2,000 external recipients/day) sending limits.
  • Zero-Pagination Option for Tenant-Wide Counts: For org-wide daily sent/received totals across all users, query the Microsoft Graph Email Activity User Detail report (`Reports.Read.All`).
Get-MessageTraceV2 -SenderAddress "[email protected]" -StartDate (Get-Date).AddDays(-7) -EndDate (Get-Date) -ResultSize 5000

Whether you are investigating a compromised account blasting spam, auditing a line-of-business SMTP relay before migrating it to Azure Communication Services, or checking why a mailbox tripped Exchange Online's 2,000 external recipients/day limit (see our Exchange Online Transport Enforcement & Throttling Runbook), you need accurate daily sent counts, top recipient domains, and peak messages-per-minute metrics.

Below is the modernized, self-contained 2026 PowerShell function (Get-ExoSentMailStatistics) rebuilt on Get-MessageTraceV2 with automatic pagination—no external GitHub downloads required.


1. Production PowerShell Function: Get-ExoSentMailStatistics (Get-MessageTraceV2)

POWERSHELL
<#
.SYNOPSIS
    Get-ExoSentMailStatistics
    Calculates daily sent email volume, top recipient domains, and peak messages/minute
    for any Exchange Online sender using Get-MessageTraceV2.
#>
function Get-ExoSentMailStatistics {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true)]
        [string]$SenderEmailAddress,

        [ValidateRange(1, 10)]
        [int]$DaysOfActivity = 7,

        [switch]$IncludeTopDomains,
        [switch]$PeakPerMinute
    )

    $endDate   = (Get-Date).ToUniversalTime()
    $startDate = $endDate.AddDays(-$DaysOfActivity)
    $allMsgs   = [System.Collections.Generic.List[object]]::new()

    Write-Host "[*] Querying Get-MessageTraceV2 for $SenderEmailAddress ($startDate to $endDate UTC)..." -ForegroundColor Cyan

    $batch = Get-MessageTraceV2 -SenderAddress $SenderEmailAddress -StartDate $startDate -EndDate $endDate -ResultSize 5000
    while ($batch) {
        $batch | ForEach-Object { $allMsgs.Add($_) }
        if ($batch.Count -lt 5000) { break }
        $last = $batch[-1]
        $batch = Get-MessageTraceV2 -SenderAddress $SenderEmailAddress `
            -StartDate $startDate `
            -EndDate $last.Received `
            -StartingRecipientAddress $last.RecipientAddress `
            -ResultSize 5000
    }

    Write-Host "[+] Total recipient deliveries analyzed: $($allMsgs.Count)`n" -ForegroundColor Green

    Write-Host "=== Daily Sent Volume ===" -ForegroundColor Cyan
    $allMsgs |
        Group-Object { $_.Received.ToString("yyyy-MM-dd") } |
        Select-Object @{N='Date';E={$_.Name}}, Count |
        Sort-Object Date -Descending |
        Format-Table -AutoSize

    if ($IncludeTopDomains) {
        Write-Host "=== Top 15 Recipient Domains ===" -ForegroundColor Cyan
        $allMsgs |
            Group-Object { ($_.RecipientAddress -split '@')[-1].ToLower() } |
            Select-Object @{N='Domain';E={$_.Name}}, Count |
            Sort-Object Count -Descending |
            Select-Object -First 15 |
            Format-Table -AutoSize
    }

    if ($PeakPerMinute) {
        Write-Host "=== Top 10 Peak Sending Minutes (Throttling Threshold: 30/min) ===" -ForegroundColor Cyan
        $allMsgs |
            Group-Object { $_.Received.ToString("yyyy-MM-dd HH:mm") } |
            Select-Object @{N='MinuteUTC';E={$_.Name}}, Count |
            Sort-Object Count -Descending |
            Select-Object -First 10 |
            Format-Table -AutoSize
    }
}

# Usage Example:
# Connect-ExchangeOnline -ShowBanner:$false
# Get-ExoSentMailStatistics -SenderEmailAddress "[email protected]" -DaysOfActivity 7 -IncludeTopDomains -PeakPerMinute

2. Tenant-Wide 30-Day Sent Statistics via Microsoft Graph (Reports.Read.All)

If you need sent and received counts across every mailbox in the entire organization (without running thousands of message traces), pull the Microsoft Graph Email Activity report in one call:

POWERSHELL
Connect-MgGraph -Scopes "Reports.Read.All" -NoWelcome

Invoke-MgGraphRequest -Method GET `
    -Uri "https://graph.microsoft.com/v1.0/reports/getEmailActivityUserDetail(period='D30')" `
    -OutputFilePath ".\M365-EmailActivity-30d.csv"

Import-Csv ".\M365-EmailActivity-30d.csv" |
    Select-Object 'User Principal Name', 'Send Count', 'Receive Count', 'Last Activity Date' |
    Sort-Object { [int]$_.'Send Count' } -Descending |
    Select-Object -First 20 |
    Format-Table -AutoSize

💬 Reader Comments & Feedback

Did this runbook help, or did Microsoft change a cmdlet or UI menu? Share your feedback below.