MacOS – How to fix Lion Mail’s search functionality

macosmail.appsearch

I made a clean install of Lion, configured Mobile Me in System Preferences.

So, when I opened Mail, my Mobile Me account was already configured and it started downloading my mails.

Everything worked fine except search. I can't search among every mails. The only search I can do using is "from" or "to" a contact of my address book.

Searching the web, I discovered some potential solutions that I tried unsuccessfully. Here's a list of what I already done :

  • repairing permissions
  • disabling Spotlight and re-enabling Spotlight for my whole disk (via the preference pane & via the terminal)
  • deleting the "envelope-index" file and get mail re-index all my mails
  • rebuilding each mailboxes
  • deleting ~/Library/Mail, ~/Library/Mail Downloads, ~/Library/Preferences/com.apple.mail.* in order to start over
  • starting again from my ~/Library/Mail folder from my Snow Leopard installation.
  • starting again without configuring Mobile Me in system preferences but directly in Mail (as different computer user)

None of these actions fixed my problem.

Have you got any ideas?

Edit :

I made a new clean install of Lion on an external hard drive, configured my Mobile Me account directly when opening Mail.app and everything worked fine. I tried to copy Mail.app-related files to my main installation of Lion, but that didn't work. My latest solution would be install Lion again on my internal hard drive, but I would prefer not to do so. I'm still hoping there's another solution.

Best Answer

I had the same problem and it turned out the index was broken.

A rebuild didn't work for me so I had to quit Mail and type (in the terminal):

cd ~/Library/Mail/V2/MailData/
rm -rf Envelope\ Index Envelope\ Index-shm  Envelope\ Index-wal

After that, reopening the Mail app took some time for the index to rebuild but it fixed the search index.

Thanks to MacRumors for the answer