SmtpBeginRelayFromEmlFile Method |
Note: This API is now obsolete.
Namespace: MailBee.SmtpMail
[ObsoleteAttribute("This method is obsolete in .NET 4.5+. Use RelayFromEmlFileAsync instead.")] public IAsyncResult BeginRelayFromEmlFile( string filename, string senderEmail, EmailAddressCollection recipients, AsyncCallback callback, Object state )
Exception | Condition |
---|---|
MailBeeInvalidStateException | There is already an operation in progress. |
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()); } }