iPhone won't delete old emails

01/06/2012: This applies to MS Exchange users only.  It may well apply to other systems, or just be useful, but only Exchange has been tested.

I had an email from Microsoft (who else) and it just stuck in my inbox on my iPhone even if it was gone from my desktop.  My inbox was always showing 1 message and whenever I deleted it it came back.  I lived with it for a while because I was worried the only solution might be to lose all of my data and start again.

The solution is simple.  First, go to iPhone settings -> Mail, contactsCaldendars -> account with the problem, e.g. Exchange - > Account button and carefully copy the details (you could do this by taking a screen shot, which is done by holding down the off button at the top and then quickly pressing the front button.)  The only thing you can't see is the password, so you need to be sure of this.  If you don't know it they you will probably need to reset it wherever the email is hosted.

Now you are going to delete the account on your iPhone.  This will delete all messages and contacts, calendars and reminders from your iPhone that are connected to this account only.  It won't delete the data from your PC or Exchange, just on your iPhone.  Go to iPhone settings -> Mail, contactsCaldendars -> account with the problem, e.g. Exchange and scroll down to the Delete Account button.  Delete the account and give the iPhone plenty of time to sort this out, although it should be pretty quick.  When done, for good measure, turn off your iPhone and turn it back on. Then check your accounts.  It should be gone.

Now go to iPhone settings -> Mail, contactsCaldendars and click the Add Account button and add it back in. Again wait for the iPhone to sort everything out and you should be back but without the annoying message.