예제 #1
0
        public List <ImapMessageRec> EnumerateMessages(ImapConnection imapConnection, FetchMessagesFlags flags, int?highFetchValue = null, int?lowFetchValue = null)
        {
            ImapMailbox imapMailbox      = imapConnection.SelectImapMailbox(this.folder);
            int?        numberOfMessages = imapMailbox.NumberOfMessages;

            if (numberOfMessages == null || numberOfMessages.Value == 0)
            {
                MrsTracer.Provider.Debug("Imap folder {0} does not have any messages to be enumerated", new object[]
                {
                    this.Name
                });
                return(new List <ImapMessageRec>(0));
            }
            int highFetchValue2 = highFetchValue ?? numberOfMessages.Value;
            int lowFetchValue2  = lowFetchValue ?? 1;
            EnumerateMessagesParams      enumerateParams = new EnumerateMessagesParams(highFetchValue2, lowFetchValue2, flags);
            IEnumerable <ImapMessageRec> collection      = this.EnumerateMessagesInfoFromImapServer(imapConnection, enumerateParams);
            List <ImapMessageRec>        list            = new List <ImapMessageRec>(collection);

            list.Sort();
            return(list);
        }
예제 #2
0
        private IEnumerable <ImapMessageRec> EnumerateMessagesInfoFromImapServer(ImapConnection imapConnection, EnumerateMessagesParams enumerateParams)
        {
            if (enumerateParams.LowFetchValue > enumerateParams.HighFetchValue)
            {
                return(new List <ImapMessageRec>(0));
            }
            ImapResultData messageInfoByRange = imapConnection.GetMessageInfoByRange(enumerateParams.LowFetchValue.ToString(CultureInfo.InvariantCulture), enumerateParams.HighFetchValue.ToString(CultureInfo.InvariantCulture), enumerateParams.FetchMessagesFlags.HasFlag(FetchMessagesFlags.FetchByUid), enumerateParams.FetchMessagesFlags.HasFlag(FetchMessagesFlags.IncludeExtendedData) ? ImapConnection.MessageInfoDataItemsForNewMessages : ImapConnection.MessageInfoDataItemsForChangesOnly);

            return(this.GetImapMessageRecsFromResultData(messageInfoByRange, enumerateParams.FetchMessagesFlags));
        }