Easiest might be to clicky and draggy the emails in some GUI client from the local folder back up to the server, or equivalent operations in e.g. mutt
with IMAP support, or a program:
https://stackoverflow.com/questions/26138604/perl-imap-move-message-to-trash-mailimapclient