How to delete mail as Admin

Copper Contributor

Hi All,

 

I am new to O365.

I am creating a phishing mail detection solution for O365. At final stage I want to purge the mail using admin credentials through java API. 

 

Can you please redirect me to correct page where I can get some inputs?

 

Regards,

Pranjal

 

 

2 Replies

Hello @pranjal sharma,

I know you are asking about API/code way to do this, but i did not have much luck finding that. In an effort to give you more information that may help your search, I wanted to give you the steps to do this in O365, and hopefully that can help you figure out if there are API ways to do this.

 

To delete a message in O365, its actually a multi-step process through the security and compliance center. (you also need a specific permission granted to do this, ediscovery admin)

 

1. Create a content search in O365 for the data in question. (based on your search and tenant size this can take anywhere from a min or two, to significantly longer).

2. Login to the Security and Compliance center on O365 via powershell

3. Delete the message through powershell

 

Here is the detailed steps - https://docs.microsoft.com/en-us/office365/securitycompliance/search-for-and-delete-messages-in-your...

I tried to find the graph API commands to correlate to this, and did not have much luck. Maybe having the steps of what you need to do as an admin can help you in your research to find the API commands. Goodluck!

 

Adam

Thanks Adam,

Actually I am using cmdlet Search-mailbox currently but this makes my code OS and powershell dependent, so I am looking for other option. Graph APIs I tried but not able to succeed in achieving the same.

Pranjal