I have uploaded all my mails from Outlook to the server (Exim) and am switching to IMAP. This all works fine, but the message index is no longer correct. Mails from 2001 are at the top because they were uploaded last.

This is not really a problem in RoundCube, Outlook or Thunderbird as they can just sort by date instead of the index. However on Android there is no such option. I also belive that sorting by index is a better solution anyway.

I would like to know if it is possible to rebuild the index and renumber mails based on the received date. Looking at the files it's just plain text so this shouldn't be too hard right?