Pop3BeginStartTls Method

Note: This API is now obsolete.

Begins an asynchronous request to start TLS/SSL negotiation with the server.

Namespace: MailBee.Pop3Mail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.2.0 build 630 for .NET 4.5
[ObsoleteAttribute("This method is obsolete in .NET 4.5+. Use StartTlsAsync instead.")]
public IAsyncResult BeginStartTls(
	AsyncCallback callback,
	Object state


Type: SystemAsyncCallback
The AsyncCallback delegate. You can leave it a null reference (Nothing in Visual Basic) if you do not use callbacks.
Type: SystemObject
An object that contains state information for this request. You can leave it a null reference (Nothing in Visual Basic).

Return Value

Type: IAsyncResult
An IAsyncResult that references the asynchronous TLS/SSL negotiation.
MailBeeInvalidStateExceptionThere is already an operation in progress.
Asynchronous TLS/SSL negotiation with the POP3 server in WinForms application. This sample also handles TlsStarted event. Wait method is used to wait for the asynchronous method completion, since .NET's standard WaitOne(Int32, Boolean) cannot process events.
// To use the code below, import MailBee namespaces at the top of your code
using MailBee;
using MailBee.Pop3Mail;

// Put the code below inside your class

// TlsStarted event handler
private void OnTlsStarted(object sender, TlsStartedEventArgs e)
    MessageBox.Show("TLS/SSL negotiation complete. Secure connection is ready.");

// The actual code
private void Form1_Load(object sender, System.EventArgs e)
    Pop3 pop = new Pop3();

    // Let MailBee process events
    pop.RaiseEventsViaMessageLoop = false;

    pop.TlsStarted += new TlsStartedEventHandler(OnTlsStarted);


    // Initiate an asynchronous TLS/SSL negotiation
    pop.BeginStartTls(null, null);

    // Simulate some lengthy work here...
    for (int i = 0; i < 100; i++)
        // Make a portion of the work

        // Process events which were raised during execution of the work above

    // If the connection was not established during execution of the lengthy 
    // work, wait until it's established

    // End the connection request

    // The connection is now under TLS/SSL layer!
    // Disconnect from the server
See Also