SmtpRelayFromEmlFile Method (String, String, EmailAddressCollection)
Relays (sends without any modifications) the mail message previously saved as an .EML file, to the specified recipients.

Namespace: MailBee.SmtpMail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 11.2.0 build 590 for .NET 4.5
public bool RelayFromEmlFile(
	string filename,
	string senderEmail,
	EmailAddressCollection recipients


Type: SystemString
The path to the file containing the message source in .EML (RFC2822) format.
Type: SystemString
The e-mail address of the sender.
Type: MailBee.MimeEmailAddressCollection
The list of the message recipients.

Return Value

Type: Boolean
true if relay succeeded; otherwise, false.
MailBeeExceptionAn error occurred and ThrowExceptions is true.

This method reads the message raw data from a file and then sends the message intact. Sender and recipients specified in the message itself (such as From: and To: fields) are ignored.

To save a message into an .EML file, SaveMessage(String) method of MailMessage object can be used.

Note Note
If Connect method was not called prior to RelayFromEmlFile(String, String, EmailAddressCollection), MailBee will call it automatically, or send the message in direct send mode (through DNS MX lookup) if no SMTP relay server is specified in SmtpServers collection or its Priority is lower than top priority of DNS servers available in DnsServers collection.
This sample relays the mail message from .EML file to the recipients, using the following configuration (which targets high reliability of send mail operation):
  1. Attempt to send to SMTP relay server at first
  2. If this fails, try to send to backup SMTP relay server at
  3. If this fails too, try direct send mode. To discover SMTP servers accepting mails for recipients domains (i.e. to perform DNS MX lookup), use DNS servers specified by the operating system
  4. If the DNS servers reported by OS are not available or down, use backup DNS server at
// To use the code below, import MailBee namespaces at the top of your code.
using MailBee;
using MailBee.SmtpMail;
using MailBee.Mime;

// The actual code (put it into a method of your class)

Smtp mailer = new Smtp();

mailer.SmtpServers.Add("", 25, 0);    // top priority.
mailer.SmtpServers.Add("", 25, 1);    // low priority.

// Auto-detect DNS servers from OS settings or config file.

// Add backup DNS server of low priority (priority of DNS servers 
// registered in OS is usually in the range 0 to 10).
mailer.DnsServers.Add("", 100);

// Send the message from the file.
mailer.RelayFromEmlFile(@"C:\Temp\message.eml", "",
    new EmailAddressCollection(""));
See Also