Hi all,

I have a problem with getting message bodies through the Object API. I'm
using C# 2.0 (VS 2005) and GW Client 7.0.3. When I try to get the text.htm
file, it works if the attachment is smaller than ~2. It fails, if the
attachment is bigger than that. Here is the code that I use to get the
attachment content:

const int BUFFER_SIZE = 1024;
int lToRead = 0, lRemainingBytes = oA.AttachmentSize;
byte[] byBuffer = new byte[BUFFER_SIZE];

lToRead = Math.Min ( lRemainingBytes, BUFFER_SIZE );
byBuffer = (byte[]) ( oStream.Read ( lToRead ) ); // this fails with

oBW.Write ( byBuffer ); // BinaryWriter
lRemainingBytes -= byBuffer.Length;
} while ( lRemainingBytes > 0 );

The same code works for a bunch of emails with HTML body, as long as the
attachment size is less than ~2 kB: in this case, the data is properly read
in chunks and the last chunk is read fine, too. (Even if lToRead less than

When I try to get the content of an attachment that is bigger than ~2 kB,
getting the very last chunk always fails. I checked the code multiple times,
it uses the correct value for lToRead, yet, the last read always fails with
the exception.

Is there anything wrong with the above code or is this a problem with the GW

Any help would be appreciated.

Gyorgy Bozoki