SmtpLowLevelDataSent Event
Occurs when data is sent to the connected socket.

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

Value

Type: MailBeeDataTransferEventHandler
Remarks

If the transmission channel is encrypted, this event will be raised each time an encrypted chunk of data is successfully sent. Thus, this event can be used to record the data which is actually sent to the network.

The typical use of this event is to calculate the network traffic produced during the SMTP session. SSL encryption increases the length of the transmitted data blocks, thus it's more accurate to calculate traffic by counting the length of data actually transmitted over the network.

If the transmission channel is not encrypted or otherwise scrambled, this property is equivalent to DataSent.

Examples
This sample calculates all outgoing traffic to the network during sending the message in direct send mode. DNS MX lookup traffic and SMTP traffic are calculated separately, and the results are printed into console.
using System;
using MailBee;
using MailBee.SmtpMail;

class Sample
{
    // Total bytes sent counters.
    private static int _totalBytesSmtp = 0;
    private static int _totalBytesDns = 0;

    // LowLevelDataSent event handler.
    private static void OnLowLevelDataSent(object sender, DataTransferEventArgs e)
    {
        if (e.Protocol == TopLevelProtocolType.Smtp)
        {
            // Increment SMTP traffic counter.
            _totalBytesSmtp += e.Data.Length;
        }
        else if (e.Protocol == TopLevelProtocolType.Dns)
        {
            // Increment DNS traffic counter.
            _totalBytesDns += e.Data.Length;
        }
    }

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

        // Get DNS servers from config file/OS settings.
        mailer.DnsServers.Autodetect();

        // Subscribe to the LowLevelDataSent event.
        mailer.LowLevelDataSent += new DataTransferEventHandler(OnLowLevelDataSent);

        // Produce some DNS and SMTP traffic by performing direct send of empty message.
        mailer.Send("sender@domain.com", "user1@domain1.com, user2@domain2.com");

        // Print the total number of bytes sent to the network.
        Console.WriteLine(_totalBytesSmtp + " bytes sent in all SMTP sessions");
        Console.WriteLine(_totalBytesDns + " bytes sent in all DNS queries");
    }
}
See Also