Occurs on progress of downloading message source data from the server.
The event handler receives an argument of type Pop3MessageDataChunkReceivedEventArgs containing data related to this event. The following Pop3MessageDataChunkReceivedEventArgs properties provide information specific to this event.
| Property | Description |
|---|---|
| BytesJustReceived | Gets the number of bytes received from the server during the operation which raised the current event. |
| EstimatedDataLength | Gets the expected length (in bytes) of the source data of the message being downloaded. |
| MessageNumber | Gets the message number (ordinal position in the mailbox) of the downloaded message. |
| State | Gets a reference to the object which was supplied by the developer in state parameter of asynchronous methods of the mailer components. |
| TotalBytesReceived | Gets the total length (in bytes) of the already received data of the message currently being downloaded. |
This event is a special case of DataReceived event. While DataReceived event occurs when any data is received, MessageDataChunkReceived event indicates message data is being received. In other words, MessageDataChunkReceived event is a filtered version of more general DataReceived event.
When both DataReceived and MessageDataChunkReceived events are used, DataReceived is raised first.
This sample completely downloads the last message in the inbox, and deletes it from the server. Both DataReceived and MessageDataChunkReceived events are handled, and the corresponding messages are printed into console when each of these events is raised. This sample demonstrates that DataReceived is raised more often than MessageDataChunkReceived.
[C#] using System; using MailBee; using MailBee.Pop3Mail; using MailBee.Mime; class Sample { // DataReceived event handler. private static void OnDataReceived(object sender, DataTransferEventArgs e) { Console.WriteLine(e.Data.Length + " bytes received"); } // 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(); // Subscribe to events. pop.DataReceived += new DataTransferEventHandler(OnDataReceived); pop.MessageDataChunkReceived += new Pop3MessageDataChunkReceivedEventHandler(OnMessageDataChunkReceived); pop.Connect("mail.domain.com"); pop.Login("jdoe", "secret"); // Completely download the last message in the inbox. MailMessage msg = pop.DownloadEntireMessage(pop.InboxMessageCount); pop.Disconnect(); } }
[Visual Basic] Imports System Imports MailBee Imports MailBee.Pop3Mail Imports MailBee.Mime Class Sample ' Connected event handler. Private Shared Sub OnDataReceived(ByVal sender As Object, ByVal e As DataTransferEventArgs) Console.WriteLine(e.Data.Length & " bytes received") End Sub 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 ' The actual code. Shared Sub Main(ByVal args As String()) Dim pop As New Pop3 ' Subscribe to events. AddHandler pop.DataReceived, AddressOf OnDataReceived AddHandler pop.MessageDataChunkReceived, _ AddressOf OnMessageDataChunkReceived pop.Connect("mail.domain.com") pop.Login("jdoe", "secret") ' Completely download the last message in the inbox. Dim msg As MailMessage msg = pop.DownloadEntireMessage(pop.InboxMessageCount) pop.Disconnect() End Sub End Class
Pop3 Class | MailBee.Pop3Mail Namespace | DataReceived