Automatically delete old existing emails in Office 365

I am having difficulty on finding out how to delete all emails older than 365 days on a specific mailbox.

Please note that the search-mailbox command below does not work on Office 365.
 
search-mailbox -identity <username> -SearchQuery "Received:<$('01/01/2014')" -deletecontent

Open in new window


Thanks for your help
LVL 1
the_omnificAsked:
Who is Participating?
 
the_omnificAuthor Commented:
I know you can do this in Outlook but not in Exchange Management Console?
0
 
Naitik GamitSoftware DeveloperCommented:
this is happen bcoz of Mailbox Import Export role isn't assigned to any role group by default.

Login to ECP
Click “Roles & Auditing”
Double click on “Organization Management”
Add “Mailbox Import Export” role
Check your account is in the member list. If not add your account into the list
Wait for a while then try the cmdlet again


For Messaging Policy Refer Link:
https://technet.microsoft.com/en-us/library/dd638205.aspx
0
 
SreRajCommented:
Hi,

As per the following article, search-mailbox will work in Exchange Online. Please check the syntax. Also you would require eDiscovery Permissions to search and delete mailbox content. Second article has information regarding that.

https://technet.microsoft.com/en-us/library/dd298173(v=exchg.150).aspx

https://technet.microsoft.com/en-us/library/dd298059(v=exchg.150).aspx
0
Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

 
the_omnificAuthor Commented:
Naitik Gamit, there is no roles and auditing. And Mailbox Import Export is not apart of Office 365 (Exchange Online 2013)
 
SreRaj

PS C:\Windows\system32> search-mailbox -identity alan -SearchQuery "Received:<$('01/01/2014')" -deletecontent
search-mailbox : The term 'search-mailbox' is not recognized as the name of a
cmdlet, function, script file, or operable program. Check the spelling of the
name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ search-mailbox -identity alan -SearchQuery "Received:<$('01/01/2014')"
-deleteco ...
+ ~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (search-mailbox:String) [], Comm
   andNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
 
PS C:\Windows\system32>

Open in new window

0
 
the_omnificAuthor Commented:
The admin user running the command is a member of Discovery Management role
0
 
Alexa JacksonDigital Forensic AnalystCommented:
Hi,

As per the information and details provided by you, to automatically delete an email older than 365 days in office 365, please follow these steps:-

If you want to delete all email older than 365 days, you can create a policy to the folder in Outlook client.

•      Right click “that folder” > Properties > Policy > select Delete after 1 year (1 year).

Note: - if there is no Deleted after 1 year option, it means the retention policy assigned to you does not contain the retention tag. In this situation, if you are, the Office 365 admin, I suggest you create a new retention policy in Exchange Admin Center (“compliance management” – “ retention tags” & “retention policies”) and assign it to you via the following steps: -

•      Create a 1 year delete tag.
•      Create a retention policy and add the tag into it or add the tag in an existed policy.
•      Assign the retention policy to the dedicated user.

If not, please ask your Office 365 admin for help.

Thanks and regards
Alexa@J
0
 
the_omnificAuthor Commented:
I thought about retention policies and called Microsoft and retention policies only appy to emails from the day the retention policy is created. Not existing emails.
0
 
SreRajCommented:
You will have to establish a remote session to office 365 from the PowerShell Console. Please try following article.

https://technet.microsoft.com/en-us/library/jj984289(v=exchg.150).aspx
0
 
the_omnificAuthor Commented:
I am already remotely connected to Office 365 via remote powershell. I am able to run other commands on that environment
0
 
SreRajCommented:
This could be the problem with eDiscovery Permission then. Please try executing the command and see if the account you are using is present as Member.

Get-RoleGroupMember -Identity "Discovery Management"

Also, please connect to Office 365 Exchange Admin Center and try to do a search from

Recipients -> Compliance Management -> In-Place eDiscovery & Hold
0
 
ycdcnCommented:
You could create a rule to delete email over a certain age.
0
 
the_omnificAuthor Commented:
SreRaj running that command displays the correct members of the group.
0
 
the_omnificAuthor Commented:
I rule would only apply to new incoming and outgoing?
0
 
ycdcnCommented:
you can create a rule to apply to emails before a particular date, select delete, you can select some exceptions if you like, and then tick the box to apply to emails currently in Inbox.
0
 
the_omnificAuthor Commented:
I run a the rule in Microsoft Outlook. I couldn't find a way of doing it in O365
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.