Simplify user tasks like bulk creation, updates, password resets, deletions, license checks & more — all from one place.
🚀 Launch ToolkitManaging emails manually can be time-consuming—especially in large organizations where automation and central control are critical. Microsoft Graph PowerShell empowers IT administrators to create, read, delete, organize, and automate email operations across Microsoft 365 users using secure, script-based commands.
\If you’re looking to streamline mail-related tasks like sending emails, managing folders, or applying rules, this guide brings together the most essential scripts in one place to get you started quickly.
Microsoft 365 mail automation refers to the use of scripts and APIs to manage mailbox activities such as sending messages, reading inboxes, cleaning up folders, and applying routing rules—without manual intervention.
Admins can use PowerShell with Microsoft Graph to control user mailboxes programmatically, enabling fast, consistent, and repeatable processes across the tenant.
Automating mail operations helps administrators:
Whether you're onboarding users, setting up shared mailboxes, or auditing email behavior, automation is your best friend.
Here are the key operations you can perform using Graph PowerShell scripts—each linking to a full tutorial and example from M365Corner.
Want to send emails from a script? This command lets you create new draft or outbound messages, add content, subject lines, attachments, and more—all through PowerShell.
👉How to create emails using New-MgUserMessage
This script helps you fetch emails from a user's mailbox, including unread messages, flagged messages, or even messages from specific senders—great for monitoring and audits.
👉How to read emails using Get-MgUserMessage
Need to automate cleanup? This script lets you delete specific or filtered emails—ideal for removing spam, outdated alerts, or flagged messages no longer needed.
👉How to delete emails using Remove-MgUserMessage
Organize your inboxes by creating custom folders like "Invoices", "Approvals", or "Reports" automatically for one or many users.
👉 How to create email folders using New-MgUserMailFolder
Use this script to list all folders in a user's mailbox, check folder structure, or retrieve folder IDs for automation or reporting purposes.
👉 How to read email folders using Get-MgUserMailFolder
Clean up unused or old folders with ease. This script helps you delete folders either selectively or in bulk.
👉 How to delete email folders using Remove-MgUserMaiFolder
Set up automated rules like “Move emails from HR to ‘HR Folder’” or “Delete all emails with a specific subject.” This cmdlet builds custom rules for mail sorting and automation.
👉 How to create folder rules using New-MgUserMailFolderMessageRule
\Audit and review existing folder rules using this script—great for compliance checks or debugging user inbox issues.
👉 How to read folder rules using Get-MgUserMailFolderMessageRule
Remove outdated or conflicting rules using this script. You can clean up or reset folder automation for one or more users.
👉 How to delete folder rules using Remove-MgUserMailFolderMessageRule
Managing Microsoft 365 emails using Graph PowerShell allows you to automate everything—from creating messages and folders to applying rules and cleaning up mailboxes. Bookmark this page as your go-to hub for all Microsoft 365 mail management scripts!
Did You Know? Managing Microsoft 365 applications is even easier with automation. Try our Graph PowerShell scripts to automate tasks like generating reports, cleaning up inactive Teams, or assigning licenses efficiently.
Ready to get the most out of Microsoft 365 tools? Explore our free Microsoft 365 administration tools to simplify your administrative tasks and boost productivity.
© Your Site Name. All Rights Reserved. Design by HTML Codex