Others

Get Help With a PowerShell Script for Sent and Received Email Counts

Rana GarciaRana Garcia Nov 14, 2026 869 views

Question details

The user needs a PowerShell script to count sent and received emails for selected users within a date range.

Get Help With a PowerShell Script for Sent and Received Email Counts
Product
PowerShell
Device & OS
not provided
Scenario
Create a report of email activity for specific users and dates.
Observed behavior
The desired report should show sent and received email counts for the selected users and period.
Before you start

Identify your mail system, the users to include, and the date range and time zone for the report. Decide whether the counts should include internal messages and how messages with multiple recipients should be counted.

Solution 1Recommended

Request Script Guidance From a Microsoft Technical Community

Use a dedicated technical forum to get commands and filtering logic suited to your mail system.

1
Gather the requirements

List your mail system, such as Exchange Online or an on-premises mail server, the user identifiers, the date range, and the desired output format.

2
Prepare your existing code

Copy any script you have tried and note the errors or unexpected results. Remove credentials, access tokens, and sensitive user data before posting.

3
Ask the community

Go to Microsoft Q&A at https://learn.microsoft.com/en-us/answers/, select Ask a question, and include your requirements and sanitized code. Add relevant PowerShell and mail-system tags.

4
Verify the report

Run the suggested script with appropriate permissions and compare its results with a small, known set of messages before reporting on all selected users.

Request Script Guidance From a Microsoft Technical Community
Counts depend on the data source: Available commands, permissions, and historical data depend on the mail system and its retention settings. Clarify whether you need message-trace counts or mailbox item counts.
Free Microsoft Office alternative

Review Email Count Reports With WPS Spreadsheets

WPS Office is a free, lightweight alternative with a familiar interface and Microsoft Office format compatibility for an easy transition. Use WPS Spreadsheets to review an exported email count report; it does not create or fix the PowerShell script.

Review and organize exported sent and received email countsOpen and edit Microsoft Excel XLSX files and CSV reportsWork in a familiar spreadsheet interfaceUse a free, lightweight Office alternative
microsoft office alternative - wps office

Frequently Asked Questions

What information should I include in my scripting question?

Include the mail system, selected user identifiers, date range and time zone, desired output, and any existing script or error message. Remove credentials and sensitive information before posting.

Can the same PowerShell script work for every mail system?

Not necessarily. Commands, permissions, and available message data vary by mail system, so identify your service when asking for help.

Why might a report not cover the entire date range?

The mail system may no longer retain the required message data, or your account may lack access to it. Check the relevant retention settings and permissions for your data source.

Can I open the resulting report in WPS Office?

Yes. If the script exports a CSV or Excel workbook, open that file in WPS Spreadsheets to review and organize the counts.