If you have IMAP access to your account then you can do this:
telnet mailserver 143
1 login username password
2 select INBOX (or whichever folder you want to purge)
3 store 1:X +flags \deleted (where X is the highest number you want to delete, 1:1000 will delete your 1,000 oldest ones)
4 expunge INBOX
5 logout
It may take a long time for the server to remove all the messages you have flagged for deletion
If your IMAP server requires an SSL login then substitute the following for the 'telnet' command (you need to have openSSL installed for this to work).
openssl s_client -connect mailserver:993
If you want to delete the 1,000 most recent messages out of 5,000 (for example) then you would type "store 4000:5000 +flags \deleted"
-Rick