Friday, December 11, 2009

Mark all emails as read on the iPhone 3G

Now i've got 2 mail accounts setup on my iphone. My gmail account, which is push, and a POP mail account from my ISP. It all works as it should, except for when it comes time to either do a restore because the phone's crashed, or update the firmware. As soon as the phones restored i end up with hundreds of unread messages on my POP account, because I leave the message on the server so I can access them on a PC as well. Now the iPhone, unfortunately, has no inbuilt function to mark all messages as read. For this method you will need a jailbroken iphone though, because there's a couple of tools you need off Cydia. I got this method from www.missingbrace.com, but i've neatened it up abit because there's a couple of steps that are either missing or unclear in their guide. So here it goes:

Step 1. - Aquire the applications needed

Applications you'll need:
- SQLite3
- Mobile Terminal


These are both available from Cydia. Just do a search and install them on your phone.

Step 2 - Login as root


Now that you've got the tools required, comes the fun part. Start up Terminal which should be on your dash board now. You want to login as root, so the first command you'll put in is

su root

it'll then ask you for your password. By default this should be alpine, but if you've changed your SSH password(which you should do, check my other post on how to change your SSH password), it'll be whatever you set it as.

Step 3 - Login to the mail database.


What you want to do now is login to your mail database. The command line is sorta long and a tiny bit of a pain to type it in on the iphone keyboard, but you only have to do it once. The command line you want to run is:

sqlite3 /private/var/mobile/Library/Mail/Envelope\ Index 

Once that's entered, you're logged into the mail database




Step 4 - Marking your messages as read



Now that's you're logged into the database, you can go ahead and flag the messages as read. To do this you need to run 2 commands. They are:

  1. update messages set flags = flags + 1 where flags&1 = 0;  
  2. update mailboxes set unread_count = 0;  
Now it's very important you enter these exactly as they are. And make sure you double check everything before hitting enter. Also make sure you've got the semicolons(;) at the end of each line.



Step 5 - Reboot your phone.
Once the commands are inputed, hit the home button. Don't worry if your mail's still showing up as unread. Reboot your iphone, by holding down the power/sleep button and sliding to power off. Wait till it powers off, then turn it back on again. Then presto, all your mail is marked as read.


el :)

1 comment:

Unknown said...

one last note on step 5. All you really have to do is kill the Mail app, not necesarily restart the whole phone, you can do this via sbsettings, or

1. go the mail application
2. push and hold the home button for 5 or 10 seconds. It will force the app to exit. (hence restarting it)