SmtpBeginExecuteCustomCommand Method |
Note: This API is now obsolete.
Namespace: MailBee.SmtpMail
[ObsoleteAttribute("This method is obsolete in .NET 4.5+. Use ExecuteCustomCommandAsync instead.")] public IAsyncResult BeginExecuteCustomCommand( string commandString, 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. // ExecuteCustomCommand callback function. private void ExecuteCustomCommandCallback(IAsyncResult result) { Smtp mailer = (Smtp)result.AsyncState; try { // If this method does not throw exception, VRFY command // is supported, and the e-mail address validation passed. // It's up to the server to decide whether to validate just // syntax or check if such e-mail address really exists. mailer.EndExecuteCustomCommand(); MessageBox.Show("The e-mail address is correct"); } catch (MailBeeSmtpNegativeResponseException e) { MessageBox.Show(e.ResponseString); } // Close the connection. mailer.Disconnect(); } // The actual code. private void Form1_Load(object sender, System.EventArgs e) { Smtp mailer = new Smtp(); mailer.SmtpServers.Add("mail.host.com"); // Connect to SMTP server and say Hello. mailer.Connect(); mailer.Hello(); // Initiate an asynchronous e-mail address verification attempt. mailer.BeginExecuteCustomCommand("VRFY user@domain.com\r\n", new AsyncCallback(ExecuteCustomCommandCallback), mailer); }