Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import <MailCore/MailCore.h>
- #import <MailCore/MCOIMAP.h>
- - (void)loginToServer:(NSString*)server withUsername:(NSString*)username andPassword:(NSString*)password {
- MCOIMAPSession *session = [[MCOIMAPSession alloc] init];
- session.hostname = server;
- session.port = 993;
- session.username = username;
- session.password = password;
- session.connectionType = MCOConnectionTypeTLS;
- // Use credentials to fetch messages in INBOX
- MCOIndexSet *uidSet = [MCOIndexSet indexSetWithRange:MCORangeMake(1,UINT64_MAX)];
- MCOIMAPFetchMessagesOperation *fetchOp =
- [session fetchMessagesByUIDOperationWithFolder:@"INBOX"
- requestKind:MCOIMAPMessagesRequestKindHeaders
- uids:uidSet];
- [fetchOp start:^(NSError *err, NSArray *msgs, MCOIndexSet *vanished) {
- // Yay! I just logged into a mail server...
- }];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement