librelist archives

« back to archive

Setting message imap flags

Setting message imap flags

From:
Jan Chaloupecky
Date:
2012-09-14 @ 07:42
Hi,

I'm trying to set the "Seen" flag to a message in my "Sent" folder using
the -[CTCoreFolder setFlags:forMessage:] but it does not seem to work.
The code is:

CTCoreFolder *ctCoreFolder = [_ctCoreAccount folderWithPath:_currentFolder];
BOOL success = [ctCoreFolder setFlags:_coreMessage.flags | CTFlagSeen
forMessage:_coreMessage];
if (!success) {
   NSLog(@"%@",ctCoreFolder.lastError);
}


The method returns success but no flags are set. If I analyze the imap
connection, I see that client (MailCore) issues only the "Check" imap
command. I do not see any ". UID STORE 86 +FLAGS.SILENT (\Seen)":

1 OK LOGIN completed
*2 SELECT Sent
** 18 EXISTS
* 0 RECENT

* OK [UNSEEN 17] Message 17 is first unseen
* OK [UIDVALIDITY 4] UIDs valid
* OK [UIDNEXT 94] Predicted next UID
* FLAGS (\Flagged \Seen \Answered \Deleted \Draft)
* OK [PERMANENTFLAGS (\Flagged \Seen \Answered \Deleted \Draft \*)]
Permanent flags
2 OK [READ-WRITE] SELECT completed
*3 CHECK
*3 OK CHECK completed
*4 LOGOUT
** BYE logging out
4 OK LOGOUT completed



What is wrong?


regards,

Jan

PS: I resent this email from another account, so sorry if there is a
duplicate

Re: [mailcore] Setting message imap flags

From:
Matt Ronge
Date:
2012-09-18 @ 00:32
First make sure you have the latest version of MailCore.

I just tried this code against Gmail and it worked for me:

MailCoreEnableLogging();
    CTCoreAccount *account = [[CTCoreAccount alloc] init];
    BOOL success = [account connectToServer:@"imap.gmail.com" port:993 
connectionType:CTConnectionTypeTLS authType:CTImapAuthTypePlain 
login:@"username" password:@"pass"];
    if (!success) {
        NSLog(@"ERROR: %@", account.lastError);
        return NO;
    }
    NSLog(@"Folders: %@", [account allFolders]);
    CTCoreFolder *folder = [account folderWithPath:@"INBOX"];
    NSUInteger count;
    [folder totalMessageCount:&count];
    NSArray *messages = [folder messagesFromSequenceNumber:count-1 
to:count-1 withFetchAttributes:CTFetchAttrEnvelope];
    CTCoreMessage *msg = [messages lastObject];
    NSLog(@"Marking as read %d %@", msg.uid, msg.subject);
    success = [folder setFlags:msg.flags | CTFlagSeen forMessage:msg];
    if (!success) {
        NSLog(@"%@",folder.lastError);
    }


Hope that helps
--
Matt Ronge

iOS Developer & Consultant
Central Atomics Inc.
http://www.centralatomics.com






On Sep 14, 2012, at 2:42 AM, Jan Chaloupecky <jan.chaloupecky@gmail.com> wrote:

> Hi,
> 
> I'm trying to set the "Seen" flag to a message in my "Sent" folder using
the -[CTCoreFolder setFlags:forMessage:] but it does not seem to work.
> The code is:
> 
> CTCoreFolder *ctCoreFolder = [_ctCoreAccount folderWithPath:_currentFolder];
> BOOL success = [ctCoreFolder setFlags:_coreMessage.flags | CTFlagSeen 
forMessage:_coreMessage];
> if (!success) {
>    NSLog(@"%@",ctCoreFolder.lastError);
> }
> 
> 
> 
> The method returns success but no flags are set. If I analyze the imap 
connection, I see that client (MailCore) issues only the "Check" imap 
command. I do not see any ". UID STORE 86 +FLAGS.SILENT (\Seen)":
> 
> 1 OK LOGIN completed
> 2 SELECT Sent
> * 18 EXISTS
> * 0 RECENT
> 
> * OK [UNSEEN 17] Message 17 is first unseen
> * OK [UIDVALIDITY 4] UIDs valid
> * OK [UIDNEXT 94] Predicted next UID
> * FLAGS (\Flagged \Seen \Answered \Deleted \Draft)
> * OK [PERMANENTFLAGS (\Flagged \Seen \Answered \Deleted \Draft \*)] 
Permanent flags
> 2 OK [READ-WRITE] SELECT completed
> 3 CHECK
> 3 OK CHECK completed
> 4 LOGOUT
> * BYE logging out
> 4 OK LOGOUT completed
> 
> 
> 
> 
> 
> What is wrong?
> 
> 
> 
> regards,
> 
> Jan
> 
> 
> PS: I resent this email from another account, so sorry if there is a duplicate