MailMessageThrowExceptions Property |
Namespace: MailBee.Mime
If this property is set to true and an error occurs, an exception derived from MailBeeException is thrown.
Note |
---|
The code of the last occurred error is always contained in LastResult property.
The list of all error codes is available in ErrorCodes class overview.
Even if this property is set to false, the exceptions which occur due to errors in MailBee usage will still be thrown. Typical example of such errors is passing invalid arguments to methods. |
using System; using MailBee; using MailBee.Mime; class Sample { static void Main(string[] args) { MailMessage msg = new MailMessage(); // Turn off exception handling. msg.ThrowExceptions = false; // Generate an error. if (!msg.LoadMessage("Wrong Path")) { Console.WriteLine("Error occurred. Error code is " + msg.LastResult.ToString()); } // Turn on exception handling. msg.ThrowExceptions = true; // The code below will throw an exception. try { msg.LoadMessage("Wrong Path"); } catch (MailBeeException ex) { // But we catch it. We display the type of the exception. In your app, // you can check other useful properties such as Message or ErrorCode. Console.WriteLine("\r\nThe following exception was thrown:\r\n" + ex.GetType().ToString()); } } }