SmtpBeginLogin Method |
Note: This API is now obsolete.
Namespace: MailBee.SmtpMail
[ObsoleteAttribute("This method is obsolete in .NET 4.5+. Use LoginAsync instead.")] public IAsyncResult BeginLogin( AsyncCallback callback, Object state )
Exception | Condition |
---|---|
MailBeeInvalidStateException | There is already an operation in progress. |
// To use the code below, import MailBee namespaces at the top of your code. using MailBee; using MailBee.SmtpMail; // Put the code below inside your class. // Login callback function. private void LoginCallback(IAsyncResult result) { Smtp mailer = (Smtp)result.AsyncState; mailer.EndLogin(); MessageBox.Show("Authentication succeeded"); // Close the connection. mailer.Disconnect(); } // The actual code. private void Form1_Load(object sender, System.EventArgs e) { Smtp mailer = new Smtp(); mailer.SmtpServers.Add("smtp.somehost.com", "jdoe", "secret"); // Connect to SMTP server and say Hello. mailer.Connect(); mailer.Hello(); // Initiate an asynchronous authentication attempt. mailer.BeginLogin(new AsyncCallback(LoginCallback), mailer); }