ImapTlsStarted Event |
Namespace: MailBee.ImapMail
using System; using MailBee; using MailBee.ImapMail; using MailBee.Security; class Sample { // TlsStarted event handler. private static void OnTlsStarted(object sender, TlsStartedEventArgs e) { // This will happen during Login method execution. Console.WriteLine("TLS/SSL session started."); } // The actual code. static void Main(string[] args) { Imap imp = new Imap(); // Subscribe to TlsStarted event. imp.TlsStarted += new TlsStartedEventHandler(OnTlsStarted); // Notify MailBee it should start TLS/SSL session when appropriate. // The connection is made to the regular port so that STARTTLS command // will be used to start TLS/SSL session. imp.SslMode = SslStartupMode.UseStartTls; imp.Connect("imap.company.com"); Console.WriteLine("Connected to the server. Will login now..."); // TLS/SSL negotiation will take place here. Thus, user credentials // will be sent to the mail server already under secure TLS/SSL layer. imp.Login("jdoe", "secret"); Console.WriteLine("Logged in successfully."); imp.Disconnect(); } }