From a19fc91c558cc20815089affb9295ad1a726a1ab Mon Sep 17 00:00:00 2001 From: Mike Seese Date: Wed, 4 Oct 2017 17:49:29 -0400 Subject: [PATCH 1/2] Apply specific gmail imap fix that david found a long time ago --- .../ActiveUp.Net.Imap4/Imap4Client.cs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Class Library/ActiveUp.Net.Imap4/Imap4Client.cs b/Class Library/ActiveUp.Net.Imap4/Imap4Client.cs index 407f536..e3361c5 100644 --- a/Class Library/ActiveUp.Net.Imap4/Imap4Client.cs +++ b/Class Library/ActiveUp.Net.Imap4/Imap4Client.cs @@ -1006,11 +1006,26 @@ 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 + } + OnNewMessageReceived(new NewMessageReceivedEventArgs(parts[2], int.Parse(parts[1]))); + } + } } else { From 64b55172062a3428bb19d944355c8b082746da82 Mon Sep 17 00:00:00 2001 From: Mike Seese Date: Wed, 4 Oct 2017 18:36:15 -0400 Subject: [PATCH 2/2] Fix parameters for updated mesaagereceived function --- Class Library/ActiveUp.Net.Imap4/Imap4Client.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Class Library/ActiveUp.Net.Imap4/Imap4Client.cs b/Class Library/ActiveUp.Net.Imap4/Imap4Client.cs index e3361c5..376704d 100644 --- a/Class Library/ActiveUp.Net.Imap4/Imap4Client.cs +++ b/Class Library/ActiveUp.Net.Imap4/Imap4Client.cs @@ -1023,7 +1023,10 @@ public void StartIdle() Console.WriteLine("Unparsable: {0}", response); #endif } - OnNewMessageReceived(new NewMessageReceivedEventArgs(parts[2], int.Parse(parts[1]))); + else + { + OnNewMessageReceived(new NewMessageReceivedEventArgs(countInt)); + } } } }