diff --git a/ImapClient.cs b/ImapClient.cs index 8783d76..6e932f8 100644 --- a/ImapClient.cs +++ b/ImapClient.cs @@ -285,20 +285,27 @@ public virtual Mailbox Examine(string mailbox) { x = new Mailbox(mailbox); while (response.StartsWith("*")) { Match m; + m = Regex.Match(response, @"(\d+) EXISTS"); - if (m.Groups.Count > 1) { x.NumMsg = m.Groups[1].ToString().ToInt(); } + if (m.Groups.Count > 1) + x.NumMsg = m.Groups[1].ToString().ToInt(); + m = Regex.Match(response, @"(\d+) RECENT"); if (m.Groups.Count > 1) x.NumNewMsg = m.Groups[1].Value.ToInt(); + m = Regex.Match(response, @"UNSEEN (\d+)"); if (m.Groups.Count > 1) x.NumUnSeen = m.Groups[1].Value.ToInt(); + m = Regex.Match(response, @"UIDVALIDITY (\d+)"); if (m.Groups.Count > 1) x.UIDValidity = m.Groups[1].Value.ToInt(); + m = Regex.Match(response, @" FLAGS \((.*?)\)"); if (m.Groups.Count > 1) x.SetFlags(m.Groups[1].ToString()); + response = GetResponse(); } _SelectedMailbox = mailbox; diff --git a/Tests/Clients.cs b/Tests/Clients.cs index 8d3ea38..846e214 100644 --- a/Tests/Clients.cs +++ b/Tests/Clients.cs @@ -48,6 +48,7 @@ public void Message_With_Attachments() { public void Select_Folder() { using (var imap = GetClient()) { imap.SelectMailbox("Notes"); + imap.Examine("Notes").UIDValidity.ShouldBeGreaterThan(0); imap.GetMessageCount().ShouldBeInRange(1, int.MaxValue); } }