Pop3DownloadMessageHeader Method (Int32, Int32)
Downloads the header and the specified number of body lines of the message on the server.

Namespace: MailBee.Pop3Mail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 11.2.0 build 590 for .NET 4.5
public MailMessage DownloadMessageHeader(
	int index,
	int bodyLineCount


Type: SystemInt32
The ordinal position of the message in the inbox. It must be in the range from 1 to InboxMessageCount. Can be negative in the range from -1 to -InboxMessageCount, i.e. -1 denotes the last e-mail in the inbox.
Type: SystemInt32
Number of lines of the message source body to download in addition to the message source header, or -1 to download the entire message.

Return Value

Type: MailMessage
On success, a MailMessage object containing the downloaded partial message; otherwise, a null reference (Nothing in Visual Basic).
MailBeeExceptionAn error occurred and ThrowExceptions is true.

When bodyLineCount is 0, only the message header is downloaded. When bodyLineCount is -1, this method is equivalent to DownloadEntireMessage(Int32) method.

Setting bodyLineCount to a positive value allows the developer to implement message body preview feature. In this case, it's recommended to set bodyLineCount >= 20 since the first 5-15 lines of the message source body are often filled with the special information and do not contain the actual body text.

If bodyLineCount is set to a certain value (such as 100), small messages having less than 100 lines in the message source body will be downloaded completely. Larger messages will be parsed partially. For instance, if 100 body lines of the message have been received, and the message contains an attachment which starts at 80-th line and ends at 150-th line of the message source body (so it has not fitted in the 100 lines received), MailBee will still add this attachment into Attachments collection, but the attachment binary data will obviously be incomplete.

Note Note
If more than one message header is downloaded, it's recommended to use DownloadMessageHeaders(Int32, Int32, Int32) method when possible, since it can operate much faster if the server supports pipelining.
This sample downloads the header and 20 lines of the message source body for the last message in an inbox on a POP3 server, and prints the message body text (if any) MailBee managed to extract from the downloaded 20 lines of the message source body.
// To use the code below, import MailBee namespaces at the top of your code.
using MailBee;
using MailBee.Pop3Mail;
using MailBee.Mime;

// The actual code (put it into a method of your class).
Pop3 pop = new Pop3();
pop.Login("jdoe", "secret");
MailMessage msg = pop.DownloadMessageHeader(pop.InboxMessageCount, 20);
See Also