SmtpBeginConnect Method |
Note: This API is now obsolete.
Namespace: MailBee.SmtpMail
[ObsoleteAttribute("This method is obsolete in .NET 4.5+. Use ConnectAsync instead.")] public IAsyncResult BeginConnect( AsyncCallback callback, Object state )
Exception | Condition |
---|---|
MailBeeInvalidStateException | There is already an operation in progress. |
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(); } }