Seal.Model.OutputEmailDevice.SendTestEmail C# (CSharp) Method

SendTestEmail() public method

public SendTestEmail ( ) : void
return void
        public void SendTestEmail()
        {
            try
            {
                _error = "";
                _information = "";

                if (string.IsNullOrEmpty(TestEmailTo)) throw new Exception("No email address has been specified in the destination email.");
                if (string.IsNullOrEmpty(SenderEmail)) throw new Exception("No sender email address has been specified.");

                MailMessage message = new MailMessage();
                message.To.Add(TestEmailTo);
                message.From = new MailAddress(SenderEmail);
                message.Subject = "Test email";
                message.Body = "This is a test message.";
                SmtpClient.Send(message);

                _information = string.Format("A test email has been sent successfully to '{0}'. Please check your inbox...", TestEmailTo);
            }
            catch (Exception ex)
            {
                _error = ex.Message;
                if (ex.InnerException != null) _error += " " + ex.InnerException.Message.Trim();
                _information = "Error got when sending the test Email.";
            }
        }