SmtpRelayFromEmlFile Method (String, String, EmailAddressCollection) |
Namespace: MailBee.SmtpMail
public bool RelayFromEmlFile( string filename, string senderEmail, EmailAddressCollection recipients )
Exception | Condition |
---|---|
MailBeeException | An 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 |
---|
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. |
// 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("smtp1.domain.com", 25, 0); // top priority. mailer.SmtpServers.Add("smtp2.domain.com", 25, 1); // low priority. // Auto-detect DNS servers from OS settings or config file. mailer.DnsServers.Autodetect(); // 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("10.20.30.40", 100); // Send the message from the file. mailer.RelayFromEmlFile(@"C:\Temp\message.eml", "from@domain.com", new EmailAddressCollection("to@company.com"));