SmtpBeginExecuteCustomCommand Method

Note: This API is now obsolete.

Begins an asynchronous request for sending the specified user-defined command to the server and getting the response.

Namespace: MailBee.SmtpMail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 11.2.0 build 590 for .NET 4.5
Syntax
[ObsoleteAttribute("This method is obsolete in .NET 4.5+. Use ExecuteCustomCommandAsync instead.")]
public IAsyncResult BeginExecuteCustomCommand(
	string commandString,
	AsyncCallback callback,
	Object state
)

Parameters

commandString
Type: SystemString
User-defined command text (including line terminator).
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 user-defined command execution.
Exceptions
ExceptionCondition
MailBeeInvalidStateExceptionThere is already an operation in progress.
Remarks
This method is an asynchronous version of ExecuteCustomCommand(String).
Examples
This WinForms samples verifies e-mail address syntax by sending VRFY command to the SMTP server (the SMTP server must support VRFY command). The sample gets notified of VRFY command completion by using a callback function.
// 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);
}
See Also