andyedinborough / aenetmail

C# POP/IMAP Mail Client
370 stars 153 forks source link

Workaround for "more line"-responses from Exchange Server / IMAP APPEND #89

Open SteveGeorge opened 12 years ago

SteveGeorge commented 12 years ago

Hi,

working with IMAP APPEND and Exchange Server 2003 got some troubles transporting more than one mail, because the Exchange Server sometimes sends back responses with more than one line (normally one line)!

Here is an example with a "more line"-response:

command ... xm045 APPEND "testbox" {435} response ... + Ready for additional command text. ... sending the mail response ... * 9 EXISTS response ... * 1 RECENT response ... xm045 OK [APPENDUID 424 9] APPEND completed.

In such a case sending more than one mail the original code is working with the "old" (never fetched) responses ...

After changing ImapClient.cs as shown (here without interpreting the responses) everything worked fine ...

  string command = GetTag() + "APPEND " + .............
  string response = SendCommandGetResponse(command); //always a "one line"-response
  if (response.StartsWith("+")) {
    response = SendCommandGetResponse(body.ToString()); //can also be a "more line"-response !
    while (response.StartsWith("*"))
    {
        response = GetResponse();
    }
  }
jstedfast commented 10 years ago

According to the IMAP specification, every command may have any number of untagged responses (i.e. lines beginning with "*").

It's not just the APPEND command that needs to support this, it's all commands.