ImapEnvelopeDataChunkReceived Event |
Namespace: MailBee.ImapMail
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.
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(); } }