SmtpBeginHello Method

Note: This API is now obsolete.

Begins an asynchronous request for sending initial greeting to the SMTP server.

Namespace: MailBee.SmtpMail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax
[ObsoleteAttribute("This method is obsolete in .NET 4.5+. Use HelloAsync instead.")]
public IAsyncResult BeginHello(
	AsyncCallback callback,
	Object state
)

Parameters

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 greeting.
Exceptions
ExceptionCondition
MailBeeInvalidStateExceptionThere is already an operation in progress.
Remarks
Examples
This console sample connects to the SMTP server, sends greeting asynchronously, and handles ErrorOccurred event to trap the warning telling that EHLO is not supported, and HELO will be tried (this warning event will be raised only if the server is not ESMTP enabled). No callback function is used.
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();
    }
}
See Also