Exemple #1
0
        public Pop3Message(long position, long size, Socket client)
        {
            m_inboxPosition = position;
            m_messageSize   = size;
            m_client        = client;

            m_pop3State            = new Pop3StateObject();
            m_pop3State.workSocket = m_client;
            m_pop3State.sb         = new StringBuilder();

            // load email ...
            LoadEmail();

            // get body (if it exists) ...
            IEnumerator multipartEnumerator =
                MultipartEnumerator;

            while (multipartEnumerator.MoveNext())
            {
                Pop3Component multipart = (Pop3Component)
                                          multipartEnumerator.Current;

                if (multipart.IsBody)
                {
                    m_body = multipart.Data;
                    break;
                }
            }
        }
Exemple #2
0
        private void LoadEmail()
        {
            // tell pop3 server we want to start reading
            // email (m_inboxPosition) from inbox ...

            Send("retr " + m_inboxPosition);

            // start receiving email ...
            StartReceive();

            // parse email ...
            ParseEmail(
                m_pop3State.sb.ToString().Split(new char[] { '\r' }));

            // remove reading pop3State ...
            m_pop3State = null;
        }
Exemple #3
0
        private void ReceiveCallback(IAsyncResult ar)
        {
            try
            {
                // Retrieve the state object and the client socket
                // from the asynchronous state object.

                Pop3StateObject stateObj =
                    (Pop3StateObject)ar.AsyncState;

                Socket client = stateObj.workSocket;

                // Read data from the remote device.
                int bytesRead = client.EndReceive(ar);

                if (bytesRead > 0)
                {
                    // There might be more data,
                    // so store the data received so far.

                    stateObj.sb.Append(
                        Encoding.ASCII.GetString(stateObj.buffer
                                                 , 0, bytesRead));

                    // read more data from pop3 server ...
                    StartReceiveAgain(stateObj.sb.ToString());
                }
            }
            catch (Exception e)
            {
                m_manualEvent.Set();

                throw new
                      Pop3ReceiveException("RecieveCallback error" +
                                           e.ToString());
            }
        }