Pop3DownloadMessageHeaders Method (Int32, Int32, Int32)
Downloads the header and the specified number of body lines of each message in the specified range from the server.

Namespace: MailBee.Pop3Mail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.4 build 677 for .NET 4.5
Syntax
public MailMessageCollection DownloadMessageHeaders(
	int startIndex,
	int count,
	int bodyLineCount
)

Parameters

startIndex
Type: SystemInt32
The ordinal position (in the inbox) of the first message in the range to be downloaded.
count
Type: SystemInt32
Number of messages to be downloaded, or -1 to indicate that all messages in the range startIndex to InboxMessageCount must be downloaded.
bodyLineCount
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 messages.

Return Value

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

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 the POP3 server supports pipelining, this method will download all the messages in a single network operation, which greatly increases performance and reduces network traffic.
Examples
This sample downloads the header and 300 lines (approx. 20-30 KBytes) of the message source body for every message in an inbox on a POP3 server, and displays whether the messages probably contain attachments or not.
Note Note
If no attachment is found in a partial message, there is still no guarantee the message would not contain attachments if was downloaded completely; the message may just have a large body text section which spans more than 300 lines in the entire message. If more body lines (such as 1000) are downloaded with the header, attachment detection quality will be higher, but at the cost of increased network traffic with the server. Another approach is to use HasAttachments property, however, it's still not 100% accurate, because it may indicate the message does have attachments if it actually doesn't but the message header reports the message has at least one attachment.
// 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.Connect("mail.domain.com");
pop.Login("jdoe", "secret");
MailMessageCollection msgs = pop.DownloadMessageHeaders(1, -1, 300);
foreach (MailMessage msg in msgs)
{
    string attachmentStatus = msg.Attachments.Count == 0 ? "no" : "some";
    Console.WriteLine("Message #" + msg.IndexOnServer + " probably contains " + attachmentStatus + " attachment(s)");
}
pop.Disconnect();
See Also