diff --git a/Class Library/ActiveUp.Net.Imap4/Imap4Client.cs b/Class Library/ActiveUp.Net.Imap4/Imap4Client.cs index 407f536..376704d 100644 --- a/Class Library/ActiveUp.Net.Imap4/Imap4Client.cs +++ b/Class Library/ActiveUp.Net.Imap4/Imap4Client.cs @@ -1006,11 +1006,29 @@ public void StartIdle() response = sr.ReadLine(); OnTcpRead(new TcpReadEventArgs(response)); - if (response.ToUpper().IndexOf("RECENT") > 0) - OnNewMessageReceived(new NewMessageReceivedEventArgs(int.Parse(response.Split(' ')[1]))); #if DEBUG Console.WriteLine(response); #endif + + if (response != null) + { + var parts = response.Split(' '); + // SPLIT something like "* 28 EXISTS" into its parts + if (parts.Length > 2) + { + int countInt; + if (!int.TryParse(parts[1], out countInt)) + { + #if DEBUG + Console.WriteLine("Unparsable: {0}", response); + #endif + } + else + { + OnNewMessageReceived(new NewMessageReceivedEventArgs(countInt)); + } + } + } } else {