You can use two solutions to automatically delete/empty mailbox on a MS Exchange Server 2010 SP1.
1) Since MS Exchange 2010 SP1 you can use Retention policies with Retention policy tags , per mailbox , easy to setup and very helpful
Emails can be auto-deleted by being marked with policy tags and after that Managed Folder Assistant “daemon” is checking the aging all the emails .
2) you can setup (in scheduled task) an exchange shell script to delete this emails :
in task scheduler add a “dos” script (ex. emptybox.bat):
PowerShell.exe -command “. ‘c:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1′; Connect-ExchangeServer -auto; C:\Scripts\cleanmbox.ps1″
and in cleanmbox.ps1 you have to set the exchange shell comand
Search-Mailbox -Identity “mailbox id1″ -DeleteContent -Force
Search-Mailbox -Identity “mailbox id2″ -DeleteContent -Force
-you can set several commands in the same file to empty mailbox for multiple accounts
-use “-Force” to avoid confirmation dialogs
On earlier (e.g. exchange 2010 RTM) use : Get-Mailbox -Database DB1 | Export-Mailbox -SubjectKeywords “Virus message” -DeleteContent