SmtpBeginConnect Method

Note: This API is now obsolete.

Begins an asynchronous request for connecting to an SMTP server.

Namespace: MailBee.SmtpMail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax
[ObsoleteAttribute("This method is obsolete in .NET 4.5+. Use ConnectAsync instead.")]
public IAsyncResult BeginConnect(
	AsyncCallback callback,
	Object state
)

Parameters

callback
Type: SystemAsyncCallback
The AsyncCallback delegate. You can leave it a null reference (Nothing in Visual Basic) if you do not use callbacks.
state
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 POP-before-SMTP authentication.
Exceptions
ExceptionCondition
MailBeeInvalidStateExceptionThere is already an operation in progress.
Remarks
Examples
This console sample connects to the SMTP server asynchronously and handles Connected event. No callback function is used.
using System;
using MailBee;
using MailBee.SmtpMail;

class Sample
{
    // "Connected" event handler.
    private static void OnConnected(object sender, ConnectedEventArgs e)
    {
        Console.WriteLine("Successfully connected to the server.");
    }

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

        mailer.SmtpServers.Add("smtp.somehost.com");

        // Subscribe to the Connected event.
        mailer.Connected += new ConnectedEventHandler(OnConnected);

        // Initiate an asynchronous connection.
        mailer.BeginConnect(null, null);

        // Simulate some lengthy work here. At the same time, 
        // the connection with the server is established on another thread.
        System.Threading.Thread.Sleep(3000);

        // End the connection request.
        mailer.EndConnect();

        mailer.Disconnect();
    }
}
See Also