This project is read-only.

Error with anything in IMAP

Jan 21, 2011 at 5:01 AM

I am trying to use this component to view a gmail account, here is my code:

    Imap4Client client = new Imap4Client();
    client.ConnectSsl("imap.gmail.com", 993);
    client.Login("super.duh-veloper@gmail.com", "733tH4x0r");

    Mailbox inbox = client.SelectMailbox("INBOX");

    for (int index = 0; index < inbox.MessageCount - 1; index++)
    {
        Message message = inbox.Fetch.MessageObject(index);
        // TODO do stuff with the message contents
    }

If I call ANY .Fetch command, I am getting:

{"Command \"fetch 0 rfc822\" failed : 11012011594686 BAD Could not parse command\r\n"}

When I step through, the "inbox" appears to be valid and everything else seems fine except for reading the actual messages in a folder. Any ideas?? thanks

-Rob

Feb 1, 2011 at 6:48 PM

I also get these errors trying to move or delete messages.  Seems to be something with the message indexes.  I don't think they start at 0.  also the message objects IndexOnServer always seems to be 0.

Their sample project shows this (notice it starts at 1)

for (int n = 1; n < inbox.MessageCount + 1; n++) 

Feb 2, 2011 at 11:19 AM

I agree! I changed this to 1 instead of 0 and everything worked, thanks!!

Feb 4, 2011 at 11:27 AM
MessageCollection messages = inbox.SearchParse("SEARCH FLAGGED SINCE 1-Feb-1994 NOT FROM 'Smith'");
Command "search SEARCH FLAGGED SINCE 1-Feb-1994 NOT FROM 'Smith'" failed : 11020404223463 BAD Could not parse command

Or If i use 
MessageCollection messages = inbox.Search("SEARCH FLAGGED SINCE 1-Feb-1994 NOT FROM 'Smith'");
Command "search SEARCH FLAGGED SINCE 1-Feb-1994 NOT FROM 'Smith'" failed : 11020404223463 BAD Could not parse command
Same error occurs. 
Help documention has wrong syntax. inbox.Search("SEARCH FLAGGED SINCE 1-Feb-1994 NOT FROM "Smith")
It gives compilation error. 
Kinldy share your thoughts 
Mar 8, 2011 at 7:02 PM

TeoHina, I've been playing with search today, and a queries like this one:

MessageCollection messages = inbox.SearchPhrase("SINCE \"1-Feb-1994\"");
seem to work fine. So my guess is that you may need to remove the word SEARCH from the beginning of your queries, and enclose the values in double-quotes. Remember that double-quote characters must be escaped when used within a string, like in my example above. Please try updating your queries this way and let us know if it worked.