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.5.0 build 687 for .NET 4.5
Syntax
[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
)

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.
callback
Type: SystemAsyncCallback
The AsyncCallback delegate. You can leave it a null reference (Nothing in Visual Basic) if you do not use callbacks.
state
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.
Exceptions
ExceptionCondition
MailBeeInvalidStateExceptionThere is already an operation in progress.
Remarks
This method is an asynchronous version of DownloadMessageHeaders(Int32, Int32, Int32).
Examples
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.Connect("pop.somehost.com");
        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.
        System.Threading.Thread.Sleep(3000);

        // 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.
        pop.Disconnect();
    }
}
See Also