Fix unread emails helper for cached deliveries

When delivery method is set to cache, the helper method to find unread
messages in a mailbox can fail to correctly identify the read messages,
because it expects the object ids in the cached deliveries array and the
email spec hash to match, but I've found that this is not reliable.

This commit updates the code to use message ids rather than object ids.