SmtpMessageDataChunkSent Event
Occurs on progress of sending message source data to the SMTP server.

Namespace: MailBee.SmtpMail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.4 build 677 for .NET 4.5
public event SmtpMessageDataChunkSentEventHandler MessageDataChunkSent


Type: MailBee.SmtpMailSmtpMessageDataChunkSentEventHandler

This event is a special case of DataSent event. While DataSent event occurs when any data is sent, MessageDataChunkSent event indicates when message data is being sent. In other words, MessageDataChunkSent event is a filtered version of more general DataSent event.

When both DataSent and MessageDataChunkSent events are used, DataSent is raised first.

This sample submits a mail message to the SMTP server. Both DataSent and MessageDataChunkSent events are handled, and the corresponding messages are printed into console when each of these events is raised. This sample demonstrates that DataSent is raised more often than MessageDataChunkSent.
using System;
using MailBee;
using MailBee.SmtpMail;

class Sample
    // DataSent event handler.
    private static void OnDataSent(object sender, DataTransferEventArgs e)
        Console.WriteLine(e.Data.Length + " bytes sent");

    // MessageDataChunkSent event handler.
    private static void OnMessageDataChunkSent(object sender,
        SmtpMessageDataChunkSentEventArgs e)
        Console.WriteLine(e.BytesJustSent + " bytes of the message " +
            e.MailMessage.MessageID + " sent");

    // The actual code.
    static void Main(string[] args)
        Smtp mailer = new Smtp();

        // Specify SMTP server and enable ESMTP authentication.
        // Note, depending on your SMTP server settings, either 
        // "jdoe" or "" should be used as user account name.
        mailer.SmtpServers.Add("", "jdoe", "secret");

        // Subscribe to events.
        mailer.DataSent += new DataTransferEventHandler(OnDataSent);
        mailer.MessageDataChunkSent +=
            new SmtpMessageDataChunkSentEventHandler(OnMessageDataChunkSent);

        // Send a message (attach a big file to make the message be sent 
        // in multiple data chunks).
        mailer.To.AsString = ",";
        mailer.From.Email = "";
        mailer.Subject = "Test message";
        mailer.BodyPlainText = "The message with attachment";

        Console.WriteLine("Message sent to: " +
See Also