Example #1
0
        // ----------------------- NextEmail ----------------------------------
        public bool NextEmail( )
        {
            string returned;

            long pos;

            if (m_directPosition == -1)
            {
                if (m_inboxPosition == 0)
                {
                    pos = 1;
                }
                else
                {
                    pos = m_inboxPosition + 1;
                }
            }
            else
            {
                pos = m_directPosition + 1;
                m_directPosition = -1;
            }

            SockEx.ExpectedResponseCodes =
                new ExpectedResponseCodes(PopConstants.Ok, PopConstants.Error);
            SockEx.SendReceive("list " + pos.ToString( ) + PopConstants.CrLf);
            if (SockEx.ExpectedResponseCode == PopConstants.Error)
            {
                return(false);
            }
            else
            {
                SockEx.ThrowIfUnexpectedResponse( );
            }

            // positive response: +ok MessagePosition MessageSize.
            returned = SockEx.ResponseMessage;

            m_inboxPosition = pos;

            // strip out CRLF ...
            string[] noCr = returned.Split(new char[] { '\r' });

            // get size ...
            string[] elements = noCr[0].Split(new char[] { ' ' });

            System.Int64 size = System.Int64.Parse(elements[2]);

            // ... else read email data
            m_pop3Message = new Pop3Message(m_inboxPosition, mSockEx);

            return(true);
        }
Example #2
0
        public bool DeleteEmail()
        {
            bool ret = false;

            SockEx.ExpectedResponseCodes = new ExpectedResponseCodes(PopConstants.Ok);
            SockEx.SendReceive("dele " + m_inboxPosition);
            SockEx.ThrowIfUnexpectedResponse( );
            string returned = SockEx.ResponseMessage;

            if (Regex.Match(returned,
                            @"^.*\+OK.*$").Success)
            {
                ret = true;
            }

            return(ret);
        }