Begins an asynchronous request for a POP-before-SMTP authentication on a mail server.
An IAsyncResult that references the asynchronous POP-before-SMTP authentication.
This method is an asynchronous version of AuthPopBeforeSmtp.
| Exception Type | Condition |
|---|---|
| MailBeeInvalidStateException | There is already an operation in progress. |
This WinForms sample demonstrates how to perform POP-before-SMTP authentication asynchronously.
[C#] // 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. // The actual code. private void Form1_Load(object sender, System.EventArgs e) { Smtp mailer = new Smtp(); // Let MailBee process events. mailer.RaiseEventsViaMessageLoop = false; mailer.SmtpServers.Add("mail.domain.com"); // Initiate an asynchronous POP-before-SMTP authentication attempt. mailer.BeginAuthPopBeforeSmtp("mail.domain.com", 110, "jdoe", "secret", null, null); // Simulate some lengthy work here... for (int i = 0; i < 100; i++) { // Make a portion of the work. System.Threading.Thread.Sleep(10); // Process events which were raised during execution of the work above. mailer.Wait(0); } // End the POP-before-SMTP operation. If it's in progress at the moment // this method starts, it will wait until it's done first. mailer.EndAuthPopBeforeSmtp(); // Connect to SMTP server and say Hello. mailer.Connect(); mailer.Hello(); // Can send mail here or do whatever needed. // ... // Close the connection. mailer.Disconnect(); }
[Visual Basic] ' To use the code below, import MailBee namespaces at the top of your code. Imports MailBee Imports MailBee.SmtpMail ' Put the code below inside your class. ' The actual code. Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Dim mailer = New Smtp ' Let MailBee process events. mailer.RaiseEventsViaMessageLoop = False mailer.SmtpServers.Add("mail.domain.com") ' Initiate an asynchronous POP-before-SMTP authentication attempt. mailer.BeginAuthPopBeforeSmtp("mail.domain.com", 110, "jdoe", "secret", Nothing, Nothing) ' Simulate some lengthy work here... For i As Integer = 1 To 100 ' Make a portion of the work. System.Threading.Thread.Sleep(10) ' Process events which were raised during execution of the work above. mailer.Wait(0) Next ' End the POP-before-SMTP operation. If it's in progress at the moment ' this method starts, it will wait until it's done first. mailer.EndAuthPopBeforeSmtp() ' Connect to SMTP server and say Hello. mailer.Connect() mailer.Hello() ' Can send mail here or do whatever needed. ' ... ' Close the connection. mailer.Disconnect() End Sub
Smtp Class | MailBee.SmtpMail Namespace | AuthPopBeforeSmtp