SmtpTlsStarted Event
Occurs when the connection with the server becomes secure.

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

Value

Type: MailBeeTlsStartedEventHandler
Remarks
This event is raised when TLS/SSL negotiation completes and TLS session successfully starts. Usually, this happens as a result of successful completion of StartTls method or if automatic TLS/SSL negotiation was requested via setting SslMode property of the active SmtpServer object to non-Manual value.
Examples
This console sample demonstrates that TlsStarted event is raised during executing Hello method when SslMode property of the active SmtpServer object is set to UseStartTls value.
using System;
using MailBee;
using MailBee.SmtpMail;
using MailBee.Security;

class Sample
{
    // TlsStarted event handler.
    private static void OnTlsStarted(object sender, TlsStartedEventArgs e)
    {
        // This will happen during Hello method execution.
        Console.WriteLine("TLS/SSL session started.");
    }

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

        // Subscribe to TlsStarted event.
        mailer.TlsStarted += new TlsStartedEventHandler(OnTlsStarted);

        // Notify MailBee it should start TLS/SSL session when appropriate.
        // The connection is made to the regular port so that STLS command
        // will be used to start TLS/SSL session.
        SmtpServer server = new SmtpServer("smtp.company.com");
        server.SslMode = SslStartupMode.UseStartTls;
        mailer.SmtpServers.Add(server);

        mailer.Connect();

        Console.WriteLine("Connected to the server. Will send greeting now...");

        // TLS/SSL negotiation will take place here. Thus, any subseqeunt commands
        // such as sending user credentials or mail message submission will take
        // place under secure TLS/SSL layer.
        // Note: EHLO command will be sent twice: first, before TLS/SSL negotiation;
        // second, after. This is because capability list presented by EHLO response
        // can change after TLS negotiation.
        mailer.Hello();

        Console.WriteLine("Hello completed successfully.");

        // Can send mail, perform login or whatever here.

        mailer.Disconnect();
    }
}
See Also