How to get the statistics of a user mailbox's mails sent out the previous day in Exchange Online

Introduction

This script will generate a report about the sent items of a user mailbox.

Scenarios

This script is to help Exchange Administrators to generate a utilization report of a user mailbox. The report will contain the number of mails sent out the previous day together with the recipient number of such sent emails.

Script

You can use this script in the following way.

1. Open Windows PowerShell.

2. Type the one command< Script Path> at the Windows PowerShell Console.

For example, type C:\Script\ QueryMailboxDailyRecipient.ps1

Here are some code snippets for your reference.

PowerShell
Edit|Remove
$DeliveredEmails = Get-MessageTrace -SenderAddress $Mailbox.PrimarySmtpAddress -StartDate $Yesterday -EndDate $Today
$ReceipientAddress = @()
Foreach($SingleEmail in $DeliveredEmails)
{
    Foreach($SingleAddress in $SingleEmail.RecipientAddress)
    {
        if($ReceipientAddress -notcontains $SingleAddress)
        {
            $ReceipientAddress += $SingleAddress
        }
    }

Examples

 Example 1: Generate a detailed report about the recipients and mails sent the previous day.  The file name will be auto generated.

The sample is shown below.
QueryMailboxDailyRecipient.ps1
       Command Screenshot
:

      Result Screenshot:

 

Prerequisites

Exchange Online
Windows PowerShell 2.0

Microsoft All-In-One Script Framework is an automation script sample library for IT Professionals. The key value that All-In-One Script Framework is trying to deliver is Scenario-Focused Script Samples driven by IT Pros' real-world pains and needs. The team is monitoring all TechNet forums, IT Pros' support calls to Microsoft, and script requests submitted to TechNet Script Repository. We collect frequently asked IT scenarios, and create script samples to automate the tasks and save some time for IT Pros. The team of All-In-One Script Framework sincerely hope that these customer-driven automation script samples can help our IT community in this script-centric move.