Example #1
0
            /// <summary>
            /// Is called when LIST command has completed.
            /// </summary>
            /// <param name="op">Asynchronous operation.</param>
            private void ListCompleted(ListAsyncOP op)
            {
                try{
                    // Operation failed.
                    if(op.Error != null){
                        m_pException = op.Error;
                        m_pPop3Client.LogAddException("Exception: " + op.Error.Message,op.Error);
                        SetState(AsyncOP_State.Completed);
                    }
                    // Operation succeeded.
                    else{
                        // Fill messages info.
                        m_pPop3Client.m_pMessages = new POP3_ClientMessageCollection(m_pPop3Client);
                        foreach(string seqNo_Size in op.ResponseLines){
                            m_pPop3Client.m_pMessages.Add(Convert.ToInt32(seqNo_Size.Trim().Split(new char[]{' '})[1]));
                        }

                        // Try to UID's for messages(If server supports UIDL).
                        // Start executing LIST command.
                        POP3_Client.UidlAsyncOP uidlOP = new UidlAsyncOP();
                        uidlOP.CompletedAsync += delegate(object sender,EventArgs<UidlAsyncOP> e){
                            UidlCompleted(uidlOP);
                        };
                        if(!m_pPop3Client.UidlAsync(uidlOP)){
                            UidlCompleted(uidlOP);
                        }
                    }
                }                
                catch(Exception x){
                    m_pException = x;
                    m_pPop3Client.LogAddException("Exception: " + x.Message,x);
                    SetState(AsyncOP_State.Completed);
                }

                op.Dispose();
            }