Beispiel #1
0
        protected virtual Rfc822MessageCollection _GetMessages(IEnumerable <uint> serialNumbers, IEnumerable <string> uids)
        {
            Rfc822MessageCollection messages = new Rfc822MessageCollection();
            IList <string>          uidsList = uids.ToList();
            int i = 0;

            foreach (uint num in serialNumbers)
            {
                PopMessage message;
                string     str;
                if (this._TryGetMessage(num, uidsList[i], out message, out str))
                {
                    messages.Add(message);
                }
                else if (this.BrokenMessage == null)
                {
                    throw new Pop3ReceiveMessageException(str, message);
                }
                i++;
            }
            if (this.Completed != null)
            {
                this.Completed(this);
            }
            return(messages);
        }
Beispiel #2
0
        protected virtual Rfc822MessageCollection _GetAllMessages()
        {
            Pop3MessageUIDInfoCollection infos;
            string str;
            Rfc822MessageCollection messages = new Rfc822MessageCollection();

            if (!this._TryGetAllUIDMessages(out infos, out str))
            {
                throw new Pop3ReceiveException(str);
            }
            for (int i = 0; i < infos.Count; i++)
            {
                PopMessage         message;
                string             str2;
                Pop3MessageUIDInfo info = infos[i];
                if (this._TryGetMessage(info.SerialNumber, info.UniqueNumber, out message, out str2))
                {
                    messages.Add(message);
                }
                else if (this.BrokenMessage == null)
                {
                    throw new Pop3ReceiveMessageException(str2, message);
                }
            }
            if (this.Completed != null)
            {
                this.Completed(this);
            }
            this.State = EPop3ClientState.Awaiting;
            return(messages);
        }
Beispiel #3
0
        public virtual Rfc822MessageCollection GetAllMessages()
        {
            Pop3MessageUIDInfoCollection infos;
            string str;

            lock (this)
            {
                if (this.State != EPop3ClientState.Awaiting)
                {
                    throw new InvalidOperationException("Pop3Client doesn't allow executing multiple operations simulteneously in a few threads using one object");
                }
                this.State = EPop3ClientState.Busy;
            }
            if (this.ConnectionState != EPop3ConnectionState.Authenticated)
            {
                this.State = EPop3ClientState.Awaiting;
                throw new Pop3WrongStateException("The command cannot be executed in this state");
            }
            Rfc822MessageCollection messages = new Rfc822MessageCollection();

            if (this._TryGetAllUIDMessages(out infos, out str))
            {
                for (int i = infos.Count - 1; i > 0; i--)
                {
                    PopMessage         message;
                    string             str2;
                    Pop3MessageUIDInfo info = infos[i];
                    if (this._TryGetMessage(info.SerialNumber, info.UniqueNumber, out message, out str2))
                    {
                        messages.Add(message);
                    }
                    else if (this.BrokenMessage == null)
                    {
                        this.State = EPop3ClientState.Awaiting;
                        throw new Pop3ReceiveMessageException(str2, message);
                    }
                }
            }
            else
            {
                this.State = EPop3ClientState.Awaiting;
                throw new Pop3ReceiveException(str);
            }
            if (this.Completed != null)
            {
                this.Completed(this);
            }
            this.State = EPop3ClientState.Awaiting;
            return(messages);
        }