Archived Forum Post

Index of archived forum posts

Question:

FetchSequenceHeaders, GetEmail, and fetchSingleAsMime inconsistent size reported?

Dec 17 '12 at 09:00

Here's one that I'm seeing with Yahoo! IMAP, hopefully someone can shed some light on..

I am pulling down messages headers using FetchSequenceHeaders(...), after which I get each email header using:

CkEmail *email=0;
email = bundle->GetEmail(x);

... After doing that I take a look at the message size using the following:

email->get_Size();

Reported size for one example is 24311 bytes.

Later when I attempt to pull down the message (same message mind you, no changes)

imap.fetchsSingleAsMime(seqnum,true);

I end up with 12888 bytes of data.

Any idea why I get two different values? The same logic works fine with gMail..

Thanks!

Edit - More details. The get_Size appears to be reporting something other than the actual "size" of the message are returned by fetchSingleAsMime. However, sadly if I use "Content-Length" as the header value to check for size on Yahoo! I get a message length that results in a truncated message.


Answer

When a header-only is downloaded from an IMAP server, the size information comes from the IMAP server's response. For example:

* 2 FETCH (UID 561 FLAGS (Seen) RFC822.SIZE 59980 BODYSTRUCTURE 
((("text" "plain" ("charset" "utf-8") NIL NIL "quoted-printable" 13444 545 NIL NIL NIL)
("text" "html" ("charset" "utf-8") NIL NIL "quoted-printable" 42262 702 NIL NIL NIL) 
"alternative" ("boundary" "----=_NextPart_001_0142_01CDCE75.80E4B4A0") NIL NIL)
("image" "gif" ("name" "image001.gif") "image001.gif@01CDCE72.EA330C20" NIL 
"base64" 1960 NIL NIL NIL) "related" 
("boundary" "----=_NextPart_000_0141_01CDCE75.80E4B4A0") NIL "de") BODY[HEADER] {1571}
You can see the total size of the email is reported to be 59980 bytes. Chilkat will take this information and save it to a "ckx-imap-totalSize" header field, such as:
ckx-imap-totalSize: 59980
If this header field is present, then it is returned by email->get_Size(). Otherwise, the size of the email is computed by traversing the MIME structure and summing up the individual sizes of header+body of each MIME part.

Finally, if a header-only is downloaded using the POP3 protocol (not IMAP), then the size of the email is obtained via a separate POP3 command (either occurring at the time of download, or cached from a previous command that obtained the list of UIDL's and/or sizes). In this case, the "CKZ-HeaderOnly" email header field is added along with a "CKZ-Size" header to indicate the total size of the email. If these two fields are present, then the size reported is that of the "CKZ-Size" header field.