Don't abort on IMAP sync for non-IMAP messages

Some messages don't have any associated IMAP information (for example,
messages in the drafts folder).  I forget this could happen and
therefor didn't check that there was an IMAP ID attached to a message
before querying for it.

This simply checks that there is an IMAP ID before trying to use it.