SmtpBeginHello Method |
Note: This API is now obsolete.
Namespace: MailBee.SmtpMail
[ObsoleteAttribute("This method is obsolete in .NET 4.5+. Use HelloAsync instead.")] public IAsyncResult BeginHello( AsyncCallback callback, Object state )
Exception | Condition |
---|---|
MailBeeInvalidStateException | There is already an operation in progress. |
using System; using MailBee; using MailBee.SmtpMail; class Sample { // ErrorOccurred event handler. private static void OnErrorOccurred(object sender, ErrorEventArgs e) { if (e.Reason is MailBeeSmtpOptionalCommandNotSupportedException) { Console.WriteLine(e.Reason.Message); // EHLO not supported. } } // The actual code. static void Main(string[] args) { Smtp mailer = new Smtp(); mailer.SmtpServers.Add("mail.domain.com"); mailer.Connect(); // Subscribe to the ErrorOccurred event. We subcribe only for the time // of Hello() method execution to make sure the trapped warnings do not // relate to execution of any other methods. mailer.ErrorOccurred += new ErrorEventHandler(OnErrorOccurred); // Initiate an asynchronous greeting. mailer.BeginHello(null, null); // Simulate some lengthy work here. At the same time, // the greeting is performed on another thread. System.Threading.Thread.Sleep(1000); // End the connection request. mailer.EndHello(); mailer.ErrorOccurred -= new ErrorEventHandler(OnErrorOccurred); mailer.Disconnect(); } }