ImapEnvelopeDataChunkReceived Event
Occurs on progress of downloading FETCH responses (containing message source data, envelopes, and other message-related information) from the server.

Namespace: MailBee.ImapMail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.2.0 build 630 for .NET 4.5
public event ImapEnvelopeDataChunkReceivedEventHandler EnvelopeDataChunkReceived


Type: MailBee.ImapMailImapEnvelopeDataChunkReceivedEventHandler

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.
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.Login("", "secret");

        // Completely download the last message in the inbox.
        MailMessage msg = imp.DownloadEntireMessage(imp.MessageCount, false);

See Also