I just started using this library and I'm getting some exceptions using the code below to call GetMessages():
using (ImapClient Client = new ImapClient("imap.gmail.com", 993, true))
{
try
{
Client.Login("[email protected]", "password", AuthMethod.Login);
}
catch (InvalidCredentialsException)
{
Debug.WriteLine("The server rejected the supplied credentials");
return;
}
uint[] uids = Client.Search(SearchCondition.All());
MailMessage[] messages = Client.GetMessages(uids);
foreach(MailMessage msg in messages)
{
Debug.WriteLine(msg.Subject);
}
Client.Logout();
}
If I step through this code in the debugger, as soon as I execute the following line:
MailMessage[] messages = Client.GetMessages(uids);
I see exceptions in the debug output window like this:
A first chance exception of type 'System.ArgumentNullException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in S22.Imap.dll
A first chance exception of type 'System.ArgumentNullException' occurred in mscorlib.dll
A first chance exception of type 'System.ArgumentNullException' occurred in System.dll
A first chance exception of type 'System.ArgumentNullException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in S22.Imap.dll
A first chance exception of type 'System.ArgumentNullException' occurred in mscorlib.dll
A first chance exception of type 'System.ArgumentNullException' occurred in System.dll
A first chance exception of type 'System.ArgumentNullException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in S22.Imap.dll
A first chance exception of type 'System.ArgumentNullException' occurred in mscorlib.dll
A first chance exception of type 'System.ArgumentNullException' occurred in System.dll
A first chance exception of type 'System.ArgumentNullException' occurred in mscorlib.dll
A first chance exception of type 'System.ArgumentNullException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in S22.Imap.dll
A first chance exception of type 'System.ArgumentNullException' occurred in System.dll
This is a brand new gmail account so the inbox only contains the default new messages from Google so my loop through the messages and printing msg.Subject produces this:
Get Gmail on your mobile phone
Import your contacts and old email
Customize Gmail with colors and themes
Getting started on Google+
I tried changing my SeachCondition from .All to .Unseen and then sent a new message to the account that I'm checking. I waited about 30 seconds, then executed this code again and still got exceptions following the call to .GetMessages():
A first chance exception of type 'System.ArgumentNullException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in S22.Imap.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in S22.Imap.dll
A first chance exception of type 'System.ArgumentNullException' occurred in System.dll
Has anyone else seen this behavior before? My example code is basically identical to one of the examples found here:
https://github.com/smiley22/S22.Imap/blob/master/Examples.md#2