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.Pop3MailAssembly: 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
)
<ObsoleteAttribute("This method is obsolete in .NET 4.5+. Use DownloadEntireMessagesAsync or DownloadMessageHeadersAsync instead.")>
Public Function BeginDownloadMessages (
startIndex As Integer,
count As Integer,
bodyLineCount As Integer,
callback As AsyncCallback,
state As Object
) As IAsyncResult
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:
IAsyncResultAn
IAsyncResult that references the asynchronous downloading the message.
Exceptions Remarks 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
{
private static void OnMessageDataChunkReceived(object sender,
Pop3MessageDataChunkReceivedEventArgs e)
{
Console.WriteLine(e.BytesJustReceived + " bytes of the message #" +
e.MessageNumber + " received");
}
static void Main(string[] args)
{
Pop3 pop = new Pop3();
pop.Connect("pop.somehost.com");
pop.Login("jdoe", "secret");
pop.MessageDataChunkReceived +=
new Pop3MessageDataChunkReceivedEventHandler(OnMessageDataChunkReceived);
pop.BeginDownloadMessages(1, -1, 0, null, null);
System.Threading.Thread.Sleep(3000);
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.");
}
pop.Disconnect();
}
}
Imports System
Imports MailBee
Imports MailBee.Pop3Mail
Imports MailBee.Mime
Class Sample
Private Shared Sub OnMessageDataChunkReceived(ByVal sender As Object, _
ByVal e As Pop3MessageDataChunkReceivedEventArgs)
Console.WriteLine(e.BytesJustReceived & " bytes of the message #" & _
e.MessageNumber & " received")
End Sub
Shared Sub Main(ByVal args As String())
Dim pop As Pop3
pop.Connect("pop.somehost.com")
pop.Login("jdoe", "secret")
AddHandler pop.MessageDataChunkReceived, AddressOf OnMessageDataChunkReceived
pop.BeginDownloadMessages(1, -1, 0, Nothing, Nothing)
System.Threading.Thread.Sleep(3000)
Dim msgs As MailMessageCollection
msgs = pop.EndDownloadMessages()
For Each msg As MailMessage 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.")
Next
pop.Disconnect()
End Sub
End Class
See Also