Inbox won't fully download and throws an IMAP error

When I try to download offline my IMAP account (along with attachements) it shows this error at startup of eM Mail

03:36:13 [email protected] [IMAP]  MailClient.Accounts.ConnectionException: 

03:36:13 ()

03:36:13    at MailClient.Protocols.Imap.Synchronizer.ImapCommand.ThrowIfConnectionBroken(BasicResponse response)

03:36:13    at MailClient.Protocols.Imap.Synchronizer.PrefetchCommand.ExecuteInternal(WorkerStatus status)

03:36:13    at MailClient.Protocols.Imap.Synchronizer.ImapCommand.Execute(WorkerStatus status)

03:36:13    at MailClient.Commands.Command.Process(WorkerStatus status)

As you can see, the log message is not really helpful.
After I ignore the error, it says in left bottom part of window that “Last sync was at [hh:mm]”, which I suppose means eM Mail has finished syncing. However this is not true, because when I open the oldest messages in my inbox, it starts the download of images and other attachements.

More recent messages are loaded very quickly, so I can assume they are already downloaded and cached on disk.

My guess is, there must be somewhere a message that makes eM Mail crash.
I enabled IMAP logging, but it doesn’t contain any obivious signs of errors.

Any help would be appreciated.

With some help of debugger, I tracked down the message that was causing the problems.
It looks like eM Client sees attachements when there aren’t any, and it requests more information about them via “UID FETCH” command.

But because eM Client incorrectly recognized non-existent attachements, server is confused and returns “BYE”. Both Thunderbird and Outlook are immune to this.

Below is raw email contents, however I replaced out real sender and receiver.  I also removed several thousands of BASE64 jpeg image to keep it clean.

Received: from fmx41.pf.interia.pl (fmx41.pf.interia.pl [127.0.0.1])
 by fmx41.pf.interia.pl (INTERIA.PL) with ESMTP id 8F6A930066E
 for <example1>; Tue, 19 Aug 2014 13:32:14 +0200 (CEST)<br>X-Envelope-To: &lt;













 &gt;<br>X-Envelope-From: <example2><br>Received: from moh2-ve1.go2.pl (moh2-ve1.go2.pl [193.17.41.186])<br>	(using TLSv1 with cipher AES256-SHA (256/256 bits))<br>	(No client certificate requested)<br>	by fmx41.pf.interia.pl (INTERIA.PL) with ESMTPS<br>	for <example1>; Tue, 19 Aug 2014 13:32:13 +0200 (CEST)<br>Received: from moh2-ve1.go2.pl (unknown [10.0.0.186])<br>	by moh2-ve1.go2.pl (Postfix) with ESMTP id 7A71344DF96<br>	for <example1>; Tue, 19 Aug 2014 13:32:13 +0200 (CEST)<br>Received: from o2.pl (unknown [10.0.0.140])<br>	by moh2-ve1.go2.pl (Postfix) with SMTP<br>	for <example1>; Tue, 19 Aug 2014 13:32:13 +0200 (CEST)<br>Subject: <br>From: =?UTF-8?Q?example2?= <example2><br>To: [email protected]<br>Mime-Version: 1.0<br>Message-ID: &lt;[email protected]&gt;<br>Date: Tue, 19 Aug 2014 13:32:13 +0200<br>X-Originator: 83.3.186.173<br>Content-Type: multipart/mixed;<br>	boundary="==o2.pl-WebMail-5bf5a890.71fbf47e.26e20=="<br>X-IPL-VerifiedSender: [email protected]<br>X-Interia-Antivirus: OK<br>X-IPL-SAS-ZERO: 31591<br>X-IPL-SAS: 0<br>X-IPL-Envelope-To: [email protected]<br><br>This is a multi-part message in MIME format.<br><br>--==o2.pl-WebMail-5bf5a890.71fbf47e.26e20==<br>Content-Type: text/plain; charset="UTF-8"<br>Content-Transfer-Encoding: quoted-printable<br><br><br>--==o2.pl-WebMail-5bf5a890.71fbf47e.26e20==<br><br>--==o2.pl-WebMail-5bf5a890.71fbf47e.26e20==<br><br>--==o2.pl-WebMail-5bf5a890.71fbf47e.26e20==<br><br>--==o2.pl-WebMail-5bf5a890.71fbf47e.26e20==<br>Content-Type: image/jpeg;<br>	name="=?UTF-8?Q?CCF20140819=5F00003.jpg?="<br>Content-Disposition: attachment;<br>	filename="=?UTF-8?Q?CCF20140819=5F00003.jpg?="<br>Content-Transfer-Encoding: base64<br><br>/9j/4AAQSkZJRgABAAEBLAEsAAD//gAfTEVBRCBUZWNobm9sb2dpZXMgSW5jLiBWMS4wMQD/<br>2wCEAAkGBwgHBgkIBwgKCgkLDhgPDg0NDh0VFhEYIh4kJCIeISEmKzcuJig0KSEhMEEwNDk6<br># I removed around 20k lines that were there to keep it clean.<br>Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O//EAaIAAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYH<br>AC0AFACUALQAUAJQAtABQAUAFABQAUAFABQAUAFABQAUAFABQAUAAoAKACgAoAKACgAoAKAC<br>gAoAKACgAoAKAA0AFABQAUAHagAoABQAUAFACUALQAlAC0AFACUAFABQAUALQB//2Q==<br><br>--==o2.pl-WebMail-5bf5a890.71fbf47e.26e20==--<br><br><br></example2></example1></example1></example1></example2></example1>