If you have deleted a Office365 user account and then realize that you still need the data in its mailbox, you may be able to recover the mailbox.
First check to see whether the mailbox has been “soft-deleted”. The next command lists all mailboxes that can be recovered:
Get-Mailbox -SoftDeletedMailbox | Select UserPrincipalName, WhenSoftDeleted
Each mailbox is associated with a user principal name. To undelete the mailbox, you need to temporarily recreate this account. Next, you can undo the mailbox deletion. Simply replace the principal name in the command below:
Undo-SoftDeletedMailbox -SoftDeletedObject firstname.lastname@example.org