Exchange Server 2010 - Delete mail from all mailboxes from a specific user.

Ben Cary 1 Reputation point


We have a user, Auto Email, that sends out various reports to many users. Some of which people reply to that triggers a function in the database. The problem is there are now thousands of these emails that need purging, I need to :-

I need to delete all email sent from this account from all user mailboxes prior to 01/01/2021.

I need to delete all email sent to this account from all user mailboxes prior to 01/01/2021.

Is there a way this can be done in Powershell ?

Any help greatly appriciated


Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,397 questions
0 comments No comments
{count} votes

6 answers

Sort by: Most helpful
  1. Xzsssss 8,861 Reputation points Microsoft Vendor

    Hi @Ben Cary ,

    As Troy said, you could use Search-Mailbox to find these mails and use -DeleteContent to delete them:
    Delete received messages:

    Search-Mailbox -Identity User01 -SearchQuery ‘Received<01/01/2021’ -DeleteContent.  


    Delete Sent messages:

    Search-Mailbox -Identity User01 -SearchQuery ‘Sent<01/01/2021’ -DeleteContent  

    Note these cmdlets will permanently delete these messages, they won’t go to the recovery items folder.


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

  2. Ben Cary 1 Reputation point

    Goord morning,

    I get this far :-


    I cant see what this error means ?

    Also this look like its going to delete from the mailbox "Autoemail", I wanted to delete from all company mailboxes anything received from the account "AutoEmail" ?

    Sorry for my dumbness

  3. Ben Cary 1 Reputation point

    Thanks @Andy David - MVP

    Thanks for the reply.

    I have tried running the first one (i have created a new mailbox called tesetdelete) and put that where you have said target mailbox ?? It then asks for Folder ?


  4. Ben Cary 1 Reputation point

    Thanks @Andy David - MVP ,

    I tried and failed, maybe I should give up !


    0 comments No comments

  5. Andy David - MVP 142.8K Reputation points MVP

    Ok, try this then :) ( I dont have a 2010 server to test against). You may have to mess with it a bit and try diff things out

    Get-mailbox -result unlimited | Search-mailbox  -searchQuery {((Received -lt '01/21/2021') -and (from: Autoemail))} -TargetMailbox targetmailbox  -TargetFolder Inbox - 
    0 comments No comments