SmtpDataSent Event
Occurs when data is sent to the network.

Namespace: MailBee.SmtpMail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.4 build 677 for .NET 4.5
Syntax
public event DataTransferEventHandler DataSent

Value

Type: MailBeeDataTransferEventHandler
Remarks

Usually, this event is raised when the component sends a request to an SMTP server. If direct send mode or POP-before-SMTP authentication is used, sending DNS queries or requests to a POP3 server will also cause this event to occur. The developer can use Protocol property to determine the protocol of the data just sent.

Unlike LowLevelDataSent event, occurrence of this event indicates sending unencrypted data only. For instance, if the transmission channel is SSL-encrypted, LowLevelDataSent event indicates sending of any portion of encrypted data, while DataSent will be raised later to indicate the entire request (which was previously sent as one or several encrypted data chunks) has been sent. If the transmission channel is not encrypted or otherwise scrambled, DataSent and LowLevelDataSent are equivalent.

Unlike MessageDataChunkSent event, DataSent will be raised when any data is sent, while MessageDataChunkSent event is raised only when message header or entire message data is sent.

Examples
This sample prints all the data sent to the server during SMTP session into console.
using System;
using MailBee;
using MailBee.SmtpMail;

class Sample
{
    // DataSent event handler.
    private static void OnDataSent(object sender, DataTransferEventArgs e)
    {
        // Ignore POP3 traffic.
        if (e.Protocol == TopLevelProtocolType.Smtp)
        {
            Console.WriteLine("[" + System.Text.Encoding.Default.GetString(e.Data) + "]");
        }
    }

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

        // Specify SMTP server and enable POP-before-SMTP authentication.
        SmtpServer server = new SmtpServer("mail.domain.com");
        server.AuthPopBeforeSmtp = true;
        server.AccountName = "jdoe";
        server.Password = "secret";
        mailer.SmtpServers.Add(server);

        // Subscribe to the DataSent event.
        mailer.DataSent += new DataTransferEventHandler(OnDataSent);

        // Produce some POP3 and SMTP traffic by connecting in POP-before-SMTP mode.
        mailer.Connect();
        mailer.Hello();
        mailer.Disconnect();
    }
}
See Also