Begins an asynchronous request for relaying a mail message to recipients.
An IAsyncResult that references the asynchronous relaying the message.
This method is an asynchronous version of RelayFromEmlFile.
| Exception Type | Condition |
|---|---|
| MailBeeInvalidStateException | There is already an operation in progress. |
This console sample demonstrates asynchronous relaying the mail message using direct send approach (via DNS MX lookup). No callback function is used.
[C#] using System; using MailBee; using MailBee.SmtpMail; using MailBee.Mime; class Sample { // The actual code. static void Main(string[] args) { Smtp mailer = new Smtp(); // Get the list of DNS servers from OS settings or the config file. mailer.DnsServers.Autodetect(); // Initiate an asynchronous relay. mailer.BeginRelayFromEmlFile(@"C:\Temp\message.eml", "kathy@company.com", new EmailAddressCollection("mike@domain1.com, bob@domain2.com"), null, null); // Simulate some lengthy work here. At the same time, // the message is being sent to recipients domains on another thread. System.Threading.Thread.Sleep(3000); // End the relay request. If send mail operation is still in progress, // the method will wait until it's finished. mailer.EndRelayFromEmlFile(); // Print the outcome. Console.WriteLine("Successfully sent to: " + mailer.GetAcceptedRecipients().ToString()); Console.WriteLine("Not sent to: " + mailer.GetRefusedRecipients().ToString()); } }
[Visual Basic] Imports System Imports MailBee Imports MailBee.SmtpMail Imports MailBee.Mime Class Sample ' The actual code. Shared Sub Main(ByVal args As String()) Dim mailer As New Smtp ' Get the list of DNS servers from OS settings or the config file. mailer.DnsServers.Autodetect() ' Initiate an asynchronous relay. mailer.BeginRelayFromEmlFile("C:\Temp\message.eml", "kathy@company.com", _ New EmailAddressCollection("mike@domain1.com, bob@domain2.com"), Nothing, Nothing) ' Simulate some lengthy work here. At the same time, ' the message is being sent to recipients domains on another thread. System.Threading.Thread.Sleep(3000) ' End the relay request. If send mail operation is still in progress, ' the method will wait until it's finished. mailer.EndRelayFromEmlFile() ' Print the outcome. Console.WriteLine("Successfully sent to: " & mailer.GetAcceptedRecipients().ToString()) Console.WriteLine("Not sent to: " & mailer.GetRefusedRecipients().ToString()) End Sub End Class
Smtp Class | MailBee.SmtpMail Namespace | RelayFromEmlFile