# Import the Exchange Online PowerShell module
Import-Module ExchangeOnlineManagement
# Connect to Exchange Online
Connect-ExchangeOnline -UserPrincipalName netcoreadmin@stcionline.com
# Set the date range for the report
$startDate = Get-Date "2023-12-27"
$endDate = Get-Date "2023-12-28"
# Get email delivery information for the specified period
$emailDeliveryReport = Get-MessageTrace -StartDate $startDate -EndDate $endDate
# Output the report to a CSV file
$reportPath = "C:\Users\naufil.mirsinge\Downloads\mailreport.csv"
$emailDeliveryReport | Export-Csv -Path $reportPath -NoTypeInformation
Write-Host "Email delivery report generated and saved to $reportPath"
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article