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: 11.2.0 build 590 for .NET 4.5
Syntax
public event SmtpMessageDataChunkSentEventHandler MessageDataChunkSent

Value

Type: MailBee.SmtpMailSmtpMessageDataChunkSentEventHandler
Remarks

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.

Examples
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 "jdoe@domain.com" should be used as user account name.
        mailer.SmtpServers.Add("mail.domain.com", "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 = "recipient1@domain1.com, recipient2@domain2.com";
        mailer.From.Email = "sender@domain.com";
        mailer.Subject = "Test message";
        mailer.BodyPlainText = "The message with attachment";
        mailer.AddAttachment(@"C:\bigfile.mdb");
        mailer.Send();

        Console.WriteLine("Message sent to: " +
            mailer.GetAcceptedRecipients().ToString());
    }
}
See Also