The new version of Mail stores its database in a different format than the old one, so the database has to be converted before Mail can use it. Sometimes the conversion fails because the old database is corrupt, or because of a bug in the conversion code.
What you should do depends on what kind of mail accounts you have. The first step, regardless of what else you do, is to back up all data, if you don't already have a current backup.
Please read this whole message before doing anything else. If any of it is unclear, ask for clarification before taking any of the steps. If you're not confident that you can follow the instructions, stop—don't change anything.
A. If you know that you have IMAP and/or Exchange mail accounts only
The easy way to recover is to discard the old database and start afresh. You can do that without losing any messages, provided that:
☞ All your incoming mail accounts are on an IMAP or Exchange server
☞ You store sent messages on the server
☞ You don't have any "On My Mac" mailboxes
Most well-known independent mail services such as iCloud and Gmail are based on IMAP. On the other hand, ISP-hosted mail services often use POP. If your ISP is one of your mail service providers (or the only one), you may not be able to use this procedure. See Part B below in that case.
If the conditions above are satisfied, please continue as follows.
Quit Mail if it's running.
Open the Library folder in your home folder by holding down the option key and selecting
Go ▹ Library
from the Finder menu bar. Inside it is a subfolder named "Mail." Move that folder to the Desktop. You're not moving the Mail application; you're moving a folder named "Mail."
Launch Mail. The mailboxes should be restored automatically. The messages will be downloaded from the servers, so it may take a long time if you have very large mailboxes. Some people have mailboxes in the gigabyte range, and that may be a problem if bandwidth is metered or the Internet connection is slow.
If the mailboxes are restored successfully, you can delete the folder you moved to the Desktop. You may have to recreate your Mail rules, signatures, and custom stationery. If it's important to you not to have to do all that, ask for instructions before deleting the folder.
B. If you have POP and/or "On My Mac" mailboxes, or if you don't know what you have
Move the Mail folder to the Desktop as in Part A and open it.
Press the key combination command-F to start a search. From the row of search tokens along the upper part of the window, select "Mail". Below that, set as the search criterion
Name ends with mbox
The results of the search will be a list of folders with a name ending in ".mbox". Each one represents a mailbox.
Launch Mail. All mailboxes will be empty at first, but if you have any IMAP or Exchange mailboxes (including iCloud), they should refill automatically after a delay, as in Part A. If you now have all the messages you want to keep, you can stop here. Otherwise, import from the mailboxes in the search results. As directed in the linked support article, select
Apple Mail
as the import format. You'll probably want to skip mailboxes with names such as "Deleted Messages," "Junk," "Spam," or "Trash." Some may be duplicates of what you already have; those you can delete.
In some cases, a mailbox may fail to import with an error message. If that happens, please post your results.
If all the mailboxes that you want to import do so successfully, you can delete the Mail folder on the Desktop.