Skip to content

Fetching the inbox count on POP? #82

Description

@AndrewHartAR

I want to get the newest 10 messages from the inbox of the user. On IMAP, I do this like so:

MCOIMAPSession *session = [[MCOIMAPSession alloc] init];
[session setHostname:@"imap.gmail.com"];
[session setPort:993];
[session setUsername:@"email@address.com"];
[session setPassword:@"password"];
[session setConnectionType:MCOConnectionTypeTLS];
NSString *folder = @"INBOX";
MCOIMAPFolderInfoOperation *infoOperation = [session folderInfoOperation:folder];
[infoOperation start:^(NSError *error, MCOIMAPFolderInfo *info) {
if (!error) {
NSLog(@"message count: %i", info.messageCount);
int messageCount = info.messageCount;
MCOIMAPMessagesRequestKind requestKind = MCOIMAPMessagesRequestKindHeaders;
MCOIndexSet *uids = [MCOIndexSet indexSetWithRange:MCORangeMake(MAX(messageCount - 10, 1), messageCount)];
MCOIMAPFetchMessagesOperation *fetchOperation = [session fetchMessagesByUIDOperationWithFolder:folder requestKind:requestKind uids:uids];
[fetchOperation start:^(NSError * error, NSArray * fetchedMessages, MCOIndexSet * vanishedMessages) {
//We've finished downloading the messages!
//Let's check if there was an error:
if(!error) {
//And, let's print out the messages...
for (MCOAbstractMessage *message in fetchedMessages) {
NSLog(@"message: %@", message);
[self.storedMail addObject:message.header];
}
self.numberOfMailboxesReturned++;
}
}];
}
}];

On IMAP I can run a MCOIMAPFolderInfoOperation, but there doesn't seem to be an equivelant for POP3. How would I go about getting the last 10 items on POP3?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions