This is the kind of problem best handled by someone who can inspect your settings on site. We would not want to mislead you here, since the content of the old emails is essential to be kept. You need someone who is familiar with both POP and IMAP settings and their differences. I do such services where I live. You probably will need to log in the email directly on the web browser to see what the preferences are, and if all the email you desire is on the web browser version of the email.
If it isn't, then you will want to go to folder in the Go menu of the Finder and select ~/Library as the folder to go to.
Then copy the folders of both Mail and Mail downloads to the Desktop (leaving the originals in the ~/Library folder).
This will allow you to reimport the messages that are on the computer after reconfiguring the email software properly. Mail will reimport from its menu mailboxes using its Mail menu -> Import Mailboxes command when done.
Any messages still residing in webmail are safe.