SmtpLowLevelDataReceived Event
Occurs when data is received from the connected socket.

Namespace: MailBee.SmtpMail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax
public event DataTransferEventHandler LowLevelDataReceived

Value

Type: MailBeeDataTransferEventHandler
Remarks

If the transmission channel is encrypted, this event will be raised when any encrypted chunk of data is received. Thus, this event can be used to record the data which is actually received from the network.

The typical use of this property is to calculate the network traffic produced during the SMTP session (including POP3/DNS data if any). 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 DataReceived.

Examples
This sample calculates all incoming traffic from 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 received counters.
    private static int _totalBytesSmtp = 0;
    private static int _totalBytesDns = 0;

    // LowLevelDataReceived event handler.
    private static void OnLowLevelDataReceived(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 LowLevelDataReceived event.
        mailer.LowLevelDataReceived += new DataTransferEventHandler(OnLowLevelDataReceived);

        // 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 received from the network.
        Console.WriteLine(_totalBytesSmtp + " bytes received in all SMTP sessions");
        Console.WriteLine(_totalBytesDns + " bytes received in all DNS responses");
    }
}
See Also