Check for existence of UIDNEXT before casting to long.

I'm using an IMAP server from Dreamhost.com (not sure what it's running, unfortunately) but the response did not include a UIDNEXT element, causing a crash on sync. This patch fixes it and allows the sync to go through properly.