示例#1
0
        public override List<Message> GetNewMessages()
        {
            Pop3 lPop3 = new Pop3();
              lPop3.Connect(Server, User, Password, _Secure);

              int lCount;
              int lSize;
              lPop3.GetStat(out lCount, out lSize);
              if (lCount == _Count && lSize == _Size) { return null; }

              _Count = lCount;
              _Size = lSize;

              List<Message> lResult = new List<Message>();
              for (int i = lCount; i > 0; i--)
              {
            string lId = lPop3.GetId(i);
            if (_KnownMessages.Contains(lId))
            {
              // Message is known and we can stop
              break;
            }
            else
            {
              Message lMessage = new Message();
              string lFrom, lSubject;
              lPop3.GetHeader(i, out lFrom, out lSubject);
              lMessage.From = lFrom;
              lMessage.Subject = lSubject;
              _KnownMessages.Add(lId);
              lResult.Add(lMessage);
            }
              }

              lPop3.Disconnect();

              if (lResult.Count > 0)
              {
            return lResult;
              }
              else
              {
            return null;
              }
        }