Pop3BeginDownloadMessages Method

Note: This API is now obsolete.

Begins an asynchronous request for downloading the entire or partial messages in the specified range from the server.

Namespace: MailBee.Pop3Mail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.2.0 build 630 for .NET 4.5
[ObsoleteAttribute("This method is obsolete in .NET 4.5+. Use DownloadEntireMessagesAsync or DownloadMessageHeadersAsync instead.")]
public IAsyncResult BeginDownloadMessages(
	int startIndex,
	int count,
	int bodyLineCount,
	AsyncCallback callback,
	Object state


Type: SystemInt32
The ordinal position (in the inbox) of the first message in the range to be downloaded.
Type: SystemInt32
Number of messages to be downloaded, or -1 to indicate that all messages in the range startIndex to InboxMessageCount must be downloaded.
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.
Type: SystemAsyncCallback
The AsyncCallback delegate. You can leave it a null reference (Nothing in Visual Basic) if you do not use callbacks.
Type: SystemObject
An object that contains state information for this request. You can leave it a null reference (Nothing in Visual Basic).

Return Value

Type: IAsyncResult
An IAsyncResult that references the asynchronous downloading the message.
MailBeeInvalidStateExceptionThere is already an operation in progress.
This method is an asynchronous version of DownloadMessageHeaders(Int32, Int32, Int32).
This sample asynchronously downloads headers of all the messages in the inbox. Then, it displays the following information about each message:
  • The length in bytes of the downloaded header data
  • The length in bytes of the actual message data on the server (it would be the length of the message if the entire message was downloaded)
MessageDataChunkReceived event is handled in order to track the download progress. No callback function is used. The sample is written for a console application.
using System;
using MailBee;
using MailBee.Pop3Mail;
using MailBee.Mime;

class Sample
    // MessageDataChunkReceived event handler.
    private static void OnMessageDataChunkReceived(object sender,
        Pop3MessageDataChunkReceivedEventArgs e)
        Console.WriteLine(e.BytesJustReceived + " bytes of the message #" +
            e.MessageNumber + " received");

    // The actual code.
    static void Main(string[] args)
        Pop3 pop = new Pop3();
        pop.Login("jdoe", "secret");

        // Subscribe to MessageDataChunkReceived event.
        pop.MessageDataChunkReceived +=
            new Pop3MessageDataChunkReceivedEventHandler(OnMessageDataChunkReceived);

        // Initiate an asynchronous download attempt.
        pop.BeginDownloadMessages(1, -1, 0, null, null);

        // Simulate some lengthy work here. At the same time,
        // the messages are downloaded on another thread.

        // End the messages download operation and return MailMessageCollection object.
        // If the operation is still in progress at the moment when 
        // this method starts, the method will wait until the operation completion.
        MailMessageCollection msgs = pop.EndDownloadMessages();

        foreach (MailMessage msg in msgs)
            Console.WriteLine("Message #" + msg.IndexOnServer +
                ": the length of the entire message is " + msg.SizeOnServer +
                " bytes, the length of the downloaded header is " + msg.Size + " bytes.");

        // Disconnect from the server.
See Also