Closed rageshkrishna closed 11 years ago
I've got the same problem, n =10 which is '\n'. Not all messages are erroring.
Removal of the assert seems to correctly retreive the messages.
Yes, removing the assert seems to cause no side effects, other than the loop being executed one extra time to read the ")" and ignore it. Unfortunately, I still do not know enough about IMAP parsing to make an educated guess about the right way to fix this.
It's a debug assert, so it is not executed in a release build and shouldn't be an issue in production. It is there on purpose for debugging. If everything has worked correctly, the very next character should be a )
. If it isn't, something has gone wrong. Can you send me example messages? The exact binary output would be perfect.
I'm not sure where to retreive the binary output, but this is the content of mail.base.body in GetMessages = "\n\r\nChauffeur: Bart\r\nDatum: 12 november 2012\r\nTijd geregistreerd: 0:00\r\nTijd gewerkt: 0:00\r\nTijd pauze: 0:00\r\nTijd werkoverleg: 0:00\r\nTijd reparatie: 0:00\r\nTijd overig: 0:00\r\nTijd ongeregistreerd: 0:00\r"
The new e-mail format is problematic as well:
"\n<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>\r\n
Here's one that breaks for me:
"\n* 1 FETCH (X-GM-THRID 1419886428955103010 X-GM-MSGID 1419886428955103010 X-GM-LABELS () UID 1 FLAGS (\\Seen) BODY[HEADER] {403}\r\nMIME-Version: 1.0\r\nReceived: by 10.112.9.106; Wed, 28 Nov 2012 05:26:59 -0800 (PST)\r\nDate: Wed, 28 Nov 2012 05:26:59 -0800\r\nMessage-ID: <CADoZ-ESTNAx5XMzwmHrFmRaCiGL8OfqFAq4zvynR5O4PthTzTQ@mail.gmail.com>\r\nSubject: Get started with Gmail\r\nFrom: Gmail Team <mail-noreply@google.com>\r\nTo: Test Imap <imap.test@purplebeak.com>\r\nContent-Type: multipart/alternative; boundary=089e01182b40039d4e04cf8e1f34\r\n\r\n)\r\n
Harmen, try adding this after line 416 in ImapClient.cs:
using (var mem = new System.IO.MemoryStream()) {
var data = Encoding.GetBytes(response);
mem.Write(data, 0, data.Length);
data = _Stream.Read(mail.Size);
mem.Write(data, 0, data.Length);
System.IO.File.WriteAllBytes(@"C:\temp.msg", mem.ToArray());
}
It will error out afterward, but it should log the raw email to the file c:\temp.msg
.
@andyedinborough The lack of debug logging is perhaps another issue I should create. :)
I do accept pull requests. ;]
Ragesh, I did just verify that the assertion fails when retrieving only headers. I'll get a fix out shortly.
Andy, I've send you an e-mail with the temp.msg.
This debug assertion in ImapClient.cs:
fails when running against gMail. The value of
n
is 10 in this case and the ')' is actually the next character in the stream.