Вопрос

I am able to fetch all messages using fetchMessagesByUIDOperationWithFolder:, however, message.flags all return 0 when some messages are unread, most are read and some are starred.

MCOIMAPMessagesRequestKind requestKind = MCOIMAPMessagesRequestKindHeaders;
NSString *folder = @"INBOX";
MCOIndexSet *uids = [MCOIndexSet indexSetWithRange:MCORangeMake(1, UINT64_MAX)];

MCOIMAPFetchMessagesOperation *fetchOperation = [session fetchMessagesByUIDOperationWithFolder:folder requestKind:requestKind uids:uids];
[fetchOperation start:^(NSError * error, NSArray * fetchedMessages, MCOIndexSet * vanishedMessages)
{
    if ( ! error )  {
        for ( MCOIMAPMessage * message_ in fetchedMessages )  {
           // I only want UNREAD messages.
        }
    }
}

I have tried using if ( message_.flags & MCOMessageFlagSeen ) but still, all flags return as 0.

What is the proper way to see if the message is UNREAD?

Это было полезно?

Решение

For anyone having the same issue, you need to also include the kind request for flags: MCOIMAPMessagesRequestKindFlags.

MCOIMAPMessagesRequestKind requestKind = MCOIMAPMessagesRequestKindHeaders|MCOIMAPMessagesRequestKindFlags;

Then, look for the unread flag:

for ( MCOIMAPMessage * message_ in fetchedMessages )  {
    if ( message_.flags == 0 ) {
        // I have a suspicion that this is not the correct
        // way to do this, but it seems to work the way I need.
    }
}

Другие советы

You can use 0 or better as below, which is 0 too, but who knows if they decide to change it to something else later:

if(message_.flags == MCOMessageFlagNone)
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top