Closed bhushan12 closed 11 years ago
I would suggest trying out this call and print out all folders coming in NSArray "folders", see if the folder you are trying to access comes up here.
[[MCOIMAPSession fetchAllFoldersOperation] start:^(NSError *error, NSArray *folders) ;
I am getting all folders calling "fetchAllFoldersOperation". But when I try to fetch messages from 'sent' or 'trash' or anything except Inbox folder, I am getting null messages array.
Can you please share your minified code sample, along with folder name you are passing in message fetch operation.
here is my code.. if ([dict count] > 0) { myAccountsession = [[MCOIMAPSession alloc] init]; [myAccountsession setHostname:[dict objectForKey:@"incomingserver"]]; [myAccountsession setPort:993]; [myAccountsession setUsername:[dict objectForKey:@"email"]]; [myAccountsession setPassword:[dict objectForKey:@"password"]]; [myAccountsession setConnectionType:MCOConnectionTypeTLS]; } MCOIMAPMessagesRequestKind requestKind = (MCOIMAPMessagesRequestKind) (MCOIMAPMessagesRequestKindHeaders | MCOIMAPMessagesRequestKindStructure | MCOIMAPMessagesRequestKindInternalDate | MCOIMAPMessagesRequestKindHeaderSubject | MCOIMAPMessagesRequestKindFlags); NSString *folder = foldernamestring; //foldernamestring is fetched from folders array from previous ViewController. NSLog(@"foldername to fetch mails %@",folder); imapMessagesFetchOp =[myAccountsession fetchMessagesByNumberOperationWithFolder:foldernamestring requestKind:requestKind numbers:[MCOIndexSet indexSetWithRange:fetchRange]];
[imapMessagesFetchOp setProgress:^(unsigned int progress) {
NSLog(@"Progress: %u", progress);
}];
[imapMessagesFetchOp start:
^(NSError *error, NSArray *messages, MCOIndexSet *vanishedMessages)
{
//here i should get messages
}];
What is your "fetchRange" variable value, via this code snippet its the only guy I can see as trouble. One suggestion would be to try for all messages in folder via MCORange fetchRange = MCORangeMake(1, UINT64_MAX);
Thanks @abhinavguptas I have done that already. That code is just to provide how many messages to fetch, it should not be a problem. But why I am able to fetch all folders in Yahoo but not of gmail. I changed imap.gmail.com to various protocols but no success. any clue....
humm, last thing I would suggest is printing out error variable which comes in callback block, you might have tried that.
And, enable connectionLogger to see what IMAP commands are flowing over the wire, its sometimes helpful
[imapSession setConnectionLogger:^(void * connectionID, MCOConnectionLogType type, NSData * data){
DLog(@"MCOIMAPSession: [%i] %@", type, [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
}];
hi, I tried 'setConnectionLogger' and I got below log
MCOIMAPSession: [0] 4 NO [NONEXISTENT] Unknown Mailbox: Sent Mail (Failure)
Its only 'Unknown Mailbox' I could understand as trouble, any ideas?.. I am passing 'Sent Mail' as folder name..
If it's Gmail, Sent Mail folder is usually "[Gmail]/Sent Mail" or something similar.
That worked really well. Thank you both of you @abhinavguptas and @dinhviethoa , I was manipulating folder names to make it readable and was passing same. Now I am getting messages but when I use 'folderInfoOperation' to calculate MCORange fetchrange (like in mailcore 2 iOSUITest example) befor fetching messages, I do not get any messages.
a connectionLogger would be useful to help analyze what's going on?
Hoà V. Dinh
On Monday, August 12, 2013 at 11:12 PM, bhushan12 wrote:
That worked really well. Thank you both of you @abhinavguptas (https://github.com/abhinavguptas) and @dinhviethoa (https://github.com/dinhviethoa) , I was manipulating folder names to make it readable and was passing same. Now I am getting messages but when I use 'folderInfoOperation' to calculate MCORange fetchrange (like in mailcore 2 iOSUITest example) befor fetching messages, I do not get any messages.
— Reply to this email directly or view it on GitHub (https://github.com/MailCore/mailcore2/issues/303#issuecomment-22545081).
connectionLogger gives following Log,
MCOIMAPSession: [1] 3 SELECT "[Gmail]/Drafts" MCOIMAPSession: [0] * FLAGS (\Answered \Flagged \Draft \Deleted \Seen)
Could you show the kind of code you use?
FETCH 5906112:47406368
looks wrong.
I think the range you passed is wrong.
You probably want to debug to know which range you passed.
Right my fetchRange is NULL. Working on it. Thanks @dinhviethoa )
I have fetched all mailcore folder names. please check the given link,
https://github.com/MailCore/mailcore2/issues/912#issuecomment-1323276900
With Mailcore 2 I am able to access Yahoo's almost all folders but when try for gmail , it can only access Inbox folder. Please anyone know whats going wrong.