When an email with malicious content like virus, phising, spam, etc is coming to the company we need to delete those emails from the recipients Inboxes, sometimes in the companies, an employee send an email with incorrect or offensive content, this process applies as well.
Please follow this process:
1. create the content. (based on https://docs.microsoft.com/en-us/office365/securitycompliance/content-search
Click on Content search
Create a new Search
Here we can put the conditions like sender, date range, subject, attachment, etc.
Click on save and run, its important input a name for this search.
In the open option, we can see all the searches saved
Once the search has finished, go to powershell and use the cmdlet New-ComplianceSearchAction
NOTE: to use the compliance module execute this script
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationNameMicrosoft.Exchange -ConnectionUri https://ps.compliance.protection.outlook.com/powershell-liveid/-Credential $UserCredential-Authentication Basic-AllowRedirection
Import-PSSession $Session -DisableNameChecking
You can validate the report and this task has been completed.