Quantcast
Channel: ImapX 2
Viewing all articles
Browse latest Browse all 1952

New Post: Search Query Help

$
0
0
I fixed my self in source code like as below in folder.cs
internal long[] SearchMessageIds(string query = "ALL", int count = -1)
        {
            if (_client.SelectedFolder != this && !Select())
                throw new OperationFailedException("The folder couldn't be selected for search.");

            if (query.ToUpper() == "ALL" && _client.Behavior.SearchAllNotSupported)
                query = "SINCE 0000-00-00";

            IList<string> data = new List<string>();
            if (!_client.SendAndReceive(string.Format(ImapCommands.Search, query), ref data))
                throw new ArgumentException("The search query couldn't be processed");

            var result = Expressions.SearchRex.Match(data.FirstOrDefault(Expressions.SearchRex.IsMatch) ?? "");
            if (!result.Success)
                //throw new OperationFailedException("The data returned from the server doesn't match the requirements");
                return new long[0];

            ////////////Edited by ME to get latest email
            long[] retcount;
            if (count < 0)
                retcount = result.Groups[1].Value.Trim().Split(' ').Select(long.Parse).ToArray();
            else
            {
                var arr = result.Groups[1].Value.Trim().Split(' ');
                retcount = arr.Reverse().Take(count).Select(long.Parse).ToArray();
            }
            ////////////Edited by ME 
            return retcount;
            //return count < 0
            //    ? result.Groups[1].Value.Trim().Split(' ').Select(long.Parse).ToArray()
            //    : result.Groups[1].Value.Trim().Split(' ').OrderBy(_ => _).Take(count).Select(long.Parse).ToArray();
        }

Viewing all articles
Browse latest Browse all 1952

Trending Articles