If you have a ton of email in your Outlook account that needs to go, you can permanently delete them. They should then be moved to the folder – Recoverable Items > Deletions, where they will be kept for 14 days. However, if 14 days is not enough, you can increase it to up to 30 days.
Before going forward, we must point out that you must use Exchange Online PowerShell since, at this time, it is not possible to make the changes needed from within Outlook or Outlook on the web. It’s odd, but it is what it is, so until Microsoft makes some changes, we have to work with what is available.
Keep deleted Emails for longer than 30 days in Outlook
For whatever reason, you might want to keep deleted emails for a little bit longer, and this guide will aid in achieving that task. We will cover the following:
- Select the correct permissions
- Connect Windows PowerShell to Exchange Online
- Disconnect the remote PowerShell session
1] Select the correct permissions
First thing first, and that is to assign the permissions that makes sense for this specific issue. To do this, you must visit docs.microsoft.com and check the section, Recipient provisioning permissions, and assign the one listed below on your Exchange Online server.
2] Connect Windows PowerShell to Exchange Online
In order to make things work, we must first connect your Exchange Online server with Windows PowerShell. We can do this by launching PowerShell from your local computer, and then copy and paste the following command:
$UserCredential = Get-Credential
When the dialog box comes up, please type in your school or work account, then your password, and click OK. The next step, then, is to copy and paste another command, and it goes like this:
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Also, run this command after performing the previous:
Import-PSSession $Session -DisableNameChecking
3] Disconnect the remote PowerShell session
After all of that is done, we suggest not closing Windows PowerShell outright, but instead disconnect it. You see, if you close the window, you could use up all the remote PowerShell sessions available to you, and you’ll need to wait for the sessions to expire.
To disconnect the session, then, copy and paste the following command, then run it by hitting the Enter key:
Remove-PSSession $Session
4] Change how long permanently deleted items are kept
Now its time to do what you came here to do in the first place, so please fire up Windows PowerShell again, and type the following command into the box and hit Enter:
Set-Mailbox -Identity "Emily Maier" -RetainDeletedItemsFor 30
Bear in mind that this command is for a specific mailbox. Please remove Emily Maier and replace it with the name of your preferred mailbox. Furthermore, this command will set the deletion date to 30 days.
As for making changes to all mailboxes, please copy and paste the following:
Get-Mailbox -ResultSize unlimited -Filter {(RecipientTypeDetails -eq 'UserMailbox')} | Set-Mailbox -RetainDeletedItemsFor 30
OK, so that’s it, and we are done. If you need more information visit Microsoft.com.