login about faq

We have an application that needs to read Yahoo via IMAP. For internal reasons, I need to loop twice through the message processing steps and the second time through, I am getting a weird operation and a LastResponse. Here is what the stripped down code looks like (removed our stuff and all the typical Chilkat error checking to make sure everything works right)....

CkImap imap;
CkString ckStr;
CkEmail *email;

    success = imap.UnlockComponent("*************");

success = imap.Connect(sServer);

imap.sendRawCommand("ID (\"GUID\" \"1\")");

success = imap.Login(m_csNormalizedUserName,m_csPassword);

success = imap.SelectMailbox("Inbox");

for(int iLoop = 0; iLoop < 2; iLoop++)
{
    iCount=imap.get_NumMessages();
    CkMessageSet *messageSet = 0;
    messageSet = imap.GetAllUids();

    // Temporary testing code
    i=messageSet->get_Count();
    ckStr=imap.lastResponse();
    sTemp=ckStr.getString();
    // End of Temporary testing code

    for (i = 0; i < messageSet->get_Count(); i++)
    {
        sMsgId.Format("%d",messageSet->GetId(i));

        email=imap.FetchSingle(atoi(sMsgId), TRUE);

        email->get_From(ckStr);
        m_sFrom=ckStr.getString();

        SYSTEMTIME st;
        char buf[80];
        email->get_LocalDate(st);
        sprintf(buf,"%02d/%02d/%02d %02d:%02d" ,st.wMonth,st.wDay,st.wYear-2000,st.wHour,st.wMinute);
        m_sDate=buf;

        email->get_Subject(ckStr);
        m_sSubject=ckStr.getString();

        if (email->HasPlainTextBody())
            email->GetPlainTextBody(ckStr);
        else if (email->HasHtmlBody())
            email->GetHtmlBody(ckStr);
        else
            email->get_Body(ckStr);
        m_sBody=ckStr.getString();

        if (email->get_NumAttachments()>0)
        {
            for (i=0; i<email->get_NumAttachments(); i++)
            {   
                email->GetAttachmentFilename(i,ckStr);
                sprintf(buf,"%s",ckStr.getString());
                if (i>0)
                    m_sAttach+=", ";
                m_sAttach+=buf;
            }

            // Get the attachment folder (based off of account id) for saving attachments
            email->SaveAllAttachments(sAttachFolder);
        }

        // store messages
    }

    // Check to see if messages are marked for deletion and delete them
    // Loop through each message to delete if marked
    for(i = 0; i < iMsgs; i++)
    {
        if(!m_sDelete.IsEmpty())
            imap.SetFlag(atoi(mailMessage->m_sId),TRUE,"Deleted",1);
    }

    int j=imap.Expunge();
} 
    imap.Disconnect();

The section that says TESTING CODE is what I put in to try to figure out what was going on. The first time through the loop, everything is fine. The second time, we get a 0 count and the Last Response reads:

"aaah BAD [SERVERBUG] UID FETCH Server error - Please try again later"

I can move the Loop to encompass all the code from the CONNECT down, but when I do that, sometimes Yahoo itself blocks the account because too many logins within a short period of time... that is why we moved the login steps OUT of the loop.

Any one have any suggestions or what this error message might refer to?

Thanks

asked Dec 27 '12 at 21:11

pbrama's gravatar image

pbrama
9334


To understand the problem better, set the KeepSessionLog property = true prior to connecting, and then examine the full contents of the SessionLog property after the error occurs. It should provide a detailed listing of each IMAP command sent, and each response received, leading up to the error.

The error implies that it's somehow a bug on the server side, but regardless, maybe something can be gleaned from the session log that might provide a clue on how to avoid it. For example, maybe calling imap.Noop() might be sufficient at a certain point. It's impossible to know without more detailed information.

link

answered Dec 28 '12 at 09:31

chilkat's gravatar image

chilkat ♦♦
11.8k316358421

The KeepSessionLog didn't show anything odd other than the same fail message. BUT.... putting the NOOP() right at the beginning of the loop corrected the problem.

So, I guess I'd like to know... what does a NOOP() command do? Is it like some sort of "wakeup" call?

Thanks for your help...

Pete

link

answered Dec 31 '12 at 11:51

pbrama's gravatar image

pbrama
9334

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×175
×5
×1
×1

Asked: Dec 27 '12 at 21:11

Seen: 1,588 times

Last updated: Dec 31 '12 at 11:51

powered by OSQA