我能够使用fetchMessagesByUIDOperationWithFolder:
获取所有消息,但是,当某些消息未读时,message.flags都会返回0,大多数消息都被读取,而有些消息则被加星标。
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.
}
}
}
我尝试使用if ( message_.flags & MCOMessageFlagSeen )
但仍然会将所有标记返回为 0 。
查看邮件 UNREAD 的正确方法是什么?
答案 0 :(得分:6)
对于遇到相同问题的任何人,您还需要包含对标志的类型请求:MCOIMAPMessagesRequestKindFlags
。
MCOIMAPMessagesRequestKind requestKind = MCOIMAPMessagesRequestKindHeaders|MCOIMAPMessagesRequestKindFlags;
然后,查找未读标志:
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.
}
}
答案 1 :(得分:0)
您可以使用0或更好,如下所示,也是0,但谁知道他们是否决定稍后将其更改为其他内容:
if(message_.flags == MCOMessageFlagNone)