I've been looking for a simple email retention policy script that can be run in Windows or Linux that logs into user IMAP accounts via SSL and purges all email (including email in sub-folders but not the actual folders themselves) based on whether an email exceeds a certain time period. e.g., purge all email older than 45 days.

A program that comes somewhat close to what I'm looking for is MailStore but that archives email first before purging and is too expensive. The email is already being archived, I'm just looking to purge it from each users mailbox. Unfortunately the accounts are with a 3rd party hosting provider and doesn't have anything built-in to accomplish this and Auto-Archive in Outlook is definitely out of the picture. I've tried clients such as Thunderbird but it doesn't meet my needs. It would be ideal for this script to be run using Windows Task Scheduler or Cron.

Anyone have any suggestions?

Thank you