Delete a specific email office 365

Hi guys,

Not sure if it necessary for everyone but I want to share with you this procedure.

Imagining that your boss asks for deleting a certain email from a certain mailbox in Office 365, How would you do that?:

There are two available options that we can make use:

  1. 1) Grant full permission to that mailbox and then remove manually the relevant email
  2. 2) Connect to office 365 via Powershell and delete that email.

I am going to show you the second option, after connecting to office 365 by Powershell here are the context you should need.

First of all, we have to find out some details about that email, then go on by adding the following fields: subject + date + from, so look at that

  1. Look at “[email protected]
  2. The subject “Mail subject
  3. From “[email protected]
  4. Sent 01/16/2017 5:48:49 PM ( BTW, you can give about-about this value)
  5. TargetMailBox is going to get EXCEL file with full data about mail that contains “Mail’s subject” AND From”[email protected]” AND Sent:”01/16/2017 5:48:49 PM“, before you are removing that, make sure that it is really the mail you looking for delete.
Search-Mailbox -Identity [email protected]  -SearchQuery {Subject:"Mail subject" AND From:"[email protected]" AND Sent:"01/16/2017 5:48:49 PM"} -TargetMailbox "[email protected]" -TargetFolder "inbox" -LogOnly -LogLevel Full

As soon as you locate the relevant email you can use this command to delete it:

Search-Mailbox -Identity [email protected] -SearchQuery {Subject:"Mail subject" AND From:"[email protected]" AND Sent:"01/16/2017 5:48:49 PM"} -DeleteContent