MDaemon's Account Prune feature can be used with multiple options to perform a number any number cleanup tasks in user mailbox folders or public folders.
Full documentation of the Account Prune application can be found in the \MDaemon\App\ directory by opening the AccountPrune.txt file.
In the \MDaemon\App directory, if there is not a file called Midnight.bat, create a file with this label. MDaemon will run any script using the Account Purne application each night at midnight.
Accountprune /m /d=30 /p=''Junk E-Mail.IMAP''
The above script will delete messages in all user's Junk E-Mail.IMAP folder that are older than thirty (30) days.
Administrators can use the AccountPrune.exe application in a command prompt for a one time use or using the Windows Scheduler to run at a specific interval.