SmtpBeginRelayFromEmlFile Method

Note: This API is now obsolete.

Begins an asynchronous request for relaying a mail message to recipients.

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 RelayFromEmlFileAsync instead.")]
public IAsyncResult BeginRelayFromEmlFile(
	string filename,
	string senderEmail,
	EmailAddressCollection recipients,
	AsyncCallback callback,
	Object state
)

Parameters

filename
Type: SystemString
The path to the file containing the message source in .EML (RFC2822) format.
senderEmail
Type: SystemString
The e-mail address of the sender.
recipients
Type: MailBee.MimeEmailAddressCollection
The list of the message recipients.
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 relaying the message.
Exceptions
ExceptionCondition
MailBeeInvalidStateExceptionThere is already an operation in progress.
Remarks
This method is an asynchronous version of RelayFromEmlFile(String, String, EmailAddressCollection).
Examples
This console sample demonstrates asynchronous relaying the mail message using direct send approach (via DNS MX lookup). No callback function is used.
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());
    }
}
See Also