If your mail folder is so messed up that M2 just isn't working correctly, you need to start with a fresh mail folder. But, you'll want to save your messages at least. To do this, you'll need to import messages from your broken mail folder into the new folder. Unfortunately, you can't use the Opera 7/8/9/10 importer as that will just duplicate the problems from the bad mail folder. Instead, you'll have to import using the generic mbox importer. Here's how you do that.
First, you need to back up your contacts. To do this, goto "O-Menu -> settings -> import and export -> export Opera contacts". Save the file as abook.adr.
Then, if you plan on importing into an Opera with a version less than 11.10, open abook.adr with a text editor and remove all the m2indexid lines.
For example, in Notepad++:
(Remember to revert your find and replace settings to what they were before you did this.)
The reason you have to delete those m2indexid lines is that they'll cause the index to get messed up when you import. This is fixed for Opera 11.10 though where the import will ignore those index ids.
You can also delete the 'id=' line from each contact as those are not needed either.
Then, you'll need to backup your feeds list. To do this, goto "O-Menu -> settings -> import and export -> export feed list". Save the file as feeds.opml.
Note that this will only export the list of feeds. It will not export already-fetched messages and will not export the update interval. But, that's all you can do.
Close down Opera and move the mail folder to somewhere safe.
Also, while Opera is closed, delete contacts.adr in the preferences folder. You need to do this because the IDs in the file are only valid for the bad mail folder.
See "Help -> About Opera" before you close down for the locations.
Start up Opera and set up each mail account like you would if you were just using Opera for the first time.
For each of the POP accounts you just set up, you'll need to import their corresponding messages from the bad mail folder into them. You do this one POP account at a time.
First, open accounts.ini in the bad mail folder so you can see what account number each of your POP accounts is.
Then, in Opera, goto "O-Menu -> settings -> import ant export -> import mail -> import generic mbox file".
Choose "Add folder". Then, browse to the "store/accountN" (where N is the number of the pop account) folder.
Once you have picked the folder, you have to choose what account to import into under the "import into" drop-down. Make sure to choose the correct account.
Then, click import and let Opera do its stuff. When it's finished, close out of the import dialog completely. Do not click back to try another one.
Then, repeat this step for each of the other POP accounts.
You do not need to do anything for the IMAP accounts.
First, right-click in the mail panel and set "Show messages from" to the specfic mail account you want to work with. Remember to set this back to "All" when you're done.
When importing your POP messages from the bad mail folder into the new pop account, you're going to get duplicates of any messages that are still on the server: the ones Opera fetched when you set up the account and the ones you imported.
What you want to do is delete the imported copies and not the newly fetched copies as the imported copies are not tied to the message on the server like the newly-fetched copies are.
To make this easier, there should be a filter in the mail panel that was created when you imported messages into the POP account. Find all the duplicates in that filter and permanently delete them. (In Opera 11, a Label is not created at the moment, so you can't count on this.)
Repeat this for each pop account.
Under the filter for the account that was created by the import process (in Opera 11, a Label is not created at the moment, so you can't count on this.), create a new filter named Sent. Right-click on the new Sent filter and goto properties. Create a rule that matches messages with a from header that contains your email address for the POP account. Check "Limit to parent" and click "Apply filter".
Repeat this for the other POP accounts.
Then, you'll be able to tell what imported messages are sent messages. Note that these might include drafts too.
Under the filter for the account that was created by the import process, you'll just have to manually search through the messages and delete them to move them to the trash.
Nothing you can do here except to manually reapply your labels.
You'll have to recreate and apply all your filters and re-add messages to filters that don't have any rules.
Now, you could copy the indexes from index.ini in the bad mail folder and put them in the new index.ini (while Opera is closed) while adjusting the index numbers and IDs so that each new section you add has an index and id that's one higher than the last section in the file, and adjust the "Index Count" at the top to reflect the new index count. However, in this case, you shouldn't do this unless you're certain that there's nothing messed up with the filter sections you're adding. You're trying to make sure index.ini is fresh and perfect after all.
If you have any Spam messages in the bad mail folder, they'll be imported as regular messages. You'll just have to go through the imported messages and remark them as spam.
Now that mail is all set up, you can import your contacts. Goto "O-Menu -> settings -> import and export -> import Opera contacts". Choose to import abook.adr.
Goto "O-Menu -> settings -> import and export -> import feed list".
That will import your feeds. But, you'll have to right-click on each feed and goto its properties to set the update interval to what you want. And, you'll have to go through and remark feed messages as read or delete them etc.
If you have any problems with usernames and passwords, close down Opera and delete wand.dat and opcert6.dat in the preferences folder. See "Help -> About Opera" for the location.
Then, re-enter all your usernames and passwords.
Note that this will wipe out all saved passwords. But, it will rule out password storage problems.
There you go. You should now have a nice clean mail folder with your mail restored (as much as possible).
Note that the directions above apply to replacing the mail folder in an existing Opera profile. However, the same ideas apply if you're just importing from a mail folder you previously backed up into a separate, newly-installed Opera, with a fresh mail folder with no accounts set up in it.