Occurs on progress of downloading FETCH responses (containing message source data, envelopes, and other message-related information) from the server.
The event handler receives an argument of type ImapEnvelopeDataChunkReceivedEventArgs containing data related to this event. The following ImapEnvelopeDataChunkReceivedEventArgs 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. |
| MessageNumber | Gets the message number (ordinal position in the folder) of the envelope the downloaded data chunk corresponds to. |
| 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 series of FETCH responses currently being downloaded. |
This event is a special case of DataReceived event. While DataReceived event occurs when any data is received, EnvelopeDataChunkReceived event indicates FETCH response containing envelope or message data is being received (see EnvelopeDownloaded event for more information regarding FETCH responses). In other words, EnvelopeDataChunkReceived event is a filtered version of more general DataReceived event.
When both DataReceived and EnvelopeDataChunkReceived events are used, DataReceived is raised first.
This sample completely downloads the last message in the inbox. Both DataReceived and EnvelopeDataChunkReceived 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 EnvelopeDataChunkReceived.
[C#] using System; using MailBee; using MailBee.ImapMail; using MailBee.Mime; class Sample { // DataReceived event handler. private static void OnDataReceived(object sender, DataTransferEventArgs e) { Console.WriteLine(e.Data.Length + " bytes received"); } // EnvelopeDataChunkReceived event handler. private static void OnEnvelopeDataChunkReceived(object sender, ImapEnvelopeDataChunkReceivedEventArgs e) { Console.WriteLine(e.BytesJustReceived + " bytes of the FETCH response series received"); } // The actual code. static void Main(string[] args) { Imap imp = new Imap(); // Subscribe to events. imp.DataReceived += new DataTransferEventHandler(OnDataReceived); imp.EnvelopeDataChunkReceived += new ImapEnvelopeDataChunkReceivedEventHandler(OnEnvelopeDataChunkReceived); // Connect to the server, login and select inbox. imp.Connect("imap.company.com"); imp.Login("jdoe@company.com", "secret"); imp.SelectFolder("INBOX"); // Completely download the last message in the inbox. MailMessage msg = imp.DownloadEntireMessage(imp.MessageCount, false); imp.Disconnect(); } }
[Visual Basic] Imports System Imports MailBee Imports MailBee.ImapMail Module Sample ' DataReceived event handler. Private Sub OnDataReceived(ByVal sender As Object, ByVal e As DataTransferEventArgs) Console.WriteLine(e.Data.Length & " bytes received") End Sub ' EnvelopeDataChunkReceived event handler. Private Sub OnEnvelopeDataChunkReceived(ByVal sender As Object, ByVal e As ImapEnvelopeDataChunkReceivedEventArgs) Console.WriteLine(e.BytesJustReceived & " bytes of the FETCH response series received") End Sub ' The actual code. Sub Main(ByVal args As String()) Dim imp As New Imap ' Subscribe to events. AddHandler imp.DataReceived, AddressOf OnDataReceived AddHandler imp.EnvelopeDataChunkReceived, AddressOf OnEnvelopeDataChunkReceived ' Connect to the server, login and select inbox. imp.Connect("mail.company.com") imp.Login("jdoe", "secret") imp.SelectFolder("INBOX") ' Completely download the last message in the inbox. Dim msg As MailBee.Mime.MailMessage = imp.DownloadEntireMessage(imp.MessageCount, False) imp.Disconnect() End Sub End Module
Imap Class | MailBee.ImapMail Namespace | DataReceived | EnvelopeDownloaded