Objective-C
Objective-C
Find the "Sent" IMAP Mailbox
See more IMAP Examples
Find the "Sent" IMAP mailbox. Also finds the Junk and Trash mailboxes..Chilkat Objective-C Downloads
#import <CkoImap.h>
#import <NSString.h>
#import <CkoMailboxes.h>
BOOL success = NO;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkoImap *imap = [[CkoImap alloc] init];
imap.Ssl = YES;
imap.Port = [NSNumber numberWithInt:993];
success = [imap Connect: @"imap.yourmailserver.com"];
if (success == NO) {
NSLog(@"%@",imap.LastErrorText);
return;
}
// Login or authenticate in some way..
success = [imap Login: @"your_login" password: @"your_password"];
if (success == NO) {
NSLog(@"%@",imap.LastErrorText);
return;
}
// Get the list of mailboxes.
NSString *refName = @"";
NSString *wildcardedMailbox = @"*";
BOOL subscribed = NO;
CkoMailboxes *mboxes = [[CkoMailboxes alloc] init];
success = [imap MbxList: subscribed reference: refName mbxPattern: wildcardedMailbox mboxes: mboxes];
if (success == NO) {
NSLog(@"%@",imap.LastErrorText);
return;
}
// The mailbox with the "/Sent" flag is the "Sent" mailbox.
// Likewise for Junk and Trash..
int i = 0;
while (i < [mboxes.Count intValue]) {
if ([mboxes HasFlag: [NSNumber numberWithInt: i] flagName: @"\\Sent"] == YES) {
NSLog(@"%@%@",@"Sent mailbox: ",[mboxes GetName: [NSNumber numberWithInt: i]]);
}
if ([mboxes HasFlag: [NSNumber numberWithInt: i] flagName: @"\\Junk"] == YES) {
NSLog(@"%@%@",@"Junk mailbox: ",[mboxes GetName: [NSNumber numberWithInt: i]]);
}
if ([mboxes HasFlag: [NSNumber numberWithInt: i] flagName: @"\\Trash"] == YES) {
NSLog(@"%@%@",@"Trash mailbox: ",[mboxes GetName: [NSNumber numberWithInt: i]]);
}
i = i + 1;
}
// Disconnect from the IMAP server.
success = [imap Disconnect];