Delete the same email from multiple inboxesPosted on 15 July 2019 by Beaming Support
If you believe an email contains a malicious link or attachment, or have deemed it unsuitable to be viewed by members of your organisation for any reason, you might need to bulk delete that email message from multiple mailboxes using a Powershell command.
The following instructions are for Office 365 admins that would like to delete a specific email from the inboxes of all users in the organisation.
The Powershell Command
The first thing you will need to do in order to delete the same email from multiple inboxes is connect to Office 365 using Powershell then run a report which will simply gather the information together so that you can see what will be deleted once you run the “Delete” command.
Get-Mailbox -ResultSize unlimited | search-mailbox -SearchQuery ‘(From:”Insert_Senders_Email_Address“) AND (Subject:”Insert_Subject_Of_Email“) AND (Received=Insert_Date_Recieved)’ -TargetMailbox Destination_Mailbox_for_Report -TargetFolder “Name_Of_Log_Folder” -LogOnly -LogLevel Full
The command above has sections highlighted in bold, these sections are the areas for your input. The sender’s address will need to be the full email address of the user. The subject area is more like a wildcard and will include anything that matches the statement mentioned in the quoted box. The date will need to be in the correct format for your region (Eg. 23/01/2019 in the UK).
The part of the command which specifies the destination mailbox can simply be the internal reference for the company. For example, if you connected to office 365 with ITsupport@example.com, you would merely need to put in “ITsupport” . The last section is the “Name of log folder”, this will be the name of the folder that will be created by the command within the ITSupport@example.com mailbox.
Once you run the command it will generate a CSV file with the output of the command so that you can check over which emails will be deleted.
Once you are happy that the CSV only displays the emails that you want to be delete from all mailboxes in the organisation, you can then run the following command.
Get-Mailbox -ResultSize unlimited | search-mailbox -SearchQuery ‘(From:”Insert_Senders_Email_Address“) AND (Subject:”Insert_Subject_Of_Email“) AND (Received=Insert_Date_Recieved)’ -TargetMailbox Destination_Mailbox_for_Report -TargetFolder “Name_Of_Log_Folder” –DeleteContent -Force
This will process and delete all emails matching the criteria from all mailboxes in the organisation.
A weight off your mind
Partner with Beaming for your business connectivity and let us take care of everything.
Azure AD Connect fails synchronisation after conditional access is enabled.11/09/23
Outlook hyperlink issues
Here’s how to get your Outlook hyperlinks to open in your default browser, instead of Edge.
What are the differences between distribution lists, group email, and shared email?
Explaining the different types of O365 groups, and when each should be used.
Businesses we’ve helped
- Office 365
- Managed Services
Eclipse was already using cloud services to allow them to operate flexibly. However, they weren’t sure if they had the best solution, had adequate data security or were getting value for money. Find out how Beaming helped.
Having been at the cutting edge of technology for over 130 years, Astell Scientific knows that the technology they use to support their business also needs to be kept right up to date.
- Remote Working
Double Parking Systems
Moving to a new business location can be disruptive, but Beaming helped Double Parking Systems make a smooth transition.
- Tricky Location
Fineturf supplies high performance sports pitch construction solutions to the likes of Manchester United. But pre-Beaming, their telephone and broadband supplier didn’t match that high performance
With a move to new business premises planned, Innovolo contacted various providers to enquire about connectivity, and was impressed by Beaming’s speedy – and human – response.
- Remote Working
PR Artistry is a PR and content creation company. Since 2017 everyone at PRA has worked remotely therefore a central point for the company’s connectivity & communication is essential.