Archived Forum Post

Index of archived forum posts

Question:

FetchSingleHeaderByUidl question (pop3)

Sep 11 '12 at 09:47

Hi, I use this method to get the email header and the first 100 lines of body. Is there a way to know if the first 100 lines are all lines contained in the body?

Thank you


Answer

A header is downloaded via the "TOP" command in the POP3 protocol (see RFC 1939 http://www.ietf.org/rfc/rfc1939.txt )

The TOP command downloads the MIME headers and the 1st N lines of the MIME body. MIME however, is a recursive (tree structured) format, where the MIME body may itself be 1 or more MIME messages, each with a header and body (where each body may in turn be 1 or more MIME messages, each with header and body, and so on..)

(An email with attachments, plain-text and HTML alternative bodies, etc. are "multipart" MIME messages, meaning that the Content-Type of the topmost header is something like "multipart/mixed" or "multipart/alternative", and the body is itself is composed of one or more MIME messages.)

The answer is that the TOP command pays no attention to the MIME structure. It simply returns the 1st N lines following the initial MIME header. It's impossible to know ahead of time whether you're asking for enough lines to get the entire human-readable "main text" of the email.