public static void Show(Window parent, string message, string header, string details, MessageBoxImage icon)
        {
            Icon        image = null;
            SystemSound sound = null;

            switch (icon)
            {
            case MessageBoxImage.Asterisk:
                image = SystemIcons.Asterisk;
                sound = SystemSounds.Asterisk;
                break;

            case MessageBoxImage.Error:
                image = SystemIcons.Error;
                sound = SystemSounds.Beep;
                break;

            case MessageBoxImage.Exclamation:
                image = SystemIcons.Exclamation;
                sound = SystemSounds.Exclamation;
                break;

            case MessageBoxImage.Question:
                image = SystemIcons.Question;
                sound = SystemSounds.Question;
                break;
            }
            var window = new DetailedMessageBox(parent, message, header, details, image.ToBitmap(), sound);

            window.ShowDialog();
        }
        private void okButton_Click(object sender, RoutedEventArgs e)
        {
            string host = serverBox.Text;
            int    port;
            string domain   = domainBox.Text;
            string email    = emailBox.Text;
            string password = passwordBox.Password;

            if (string.IsNullOrWhiteSpace(host) ||
                string.IsNullOrWhiteSpace(email) ||
                string.IsNullOrWhiteSpace(password) ||
                string.IsNullOrWhiteSpace(domain) ||
                !int.TryParse(portBox.Text, out port))
            {
                MessageBox.Show("You must fill in all fields", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            try
            {
                var server = new MailServer(host, port, domain);
                _client = new SmtpClient(new FileLogger(LogFile, true));
                _client.Connect(server);
                _client.Credentials = new Credentials(email, password, Encoding.UTF8);
                var mailWindow = new MainWindow(_client);
                mailWindow.Show();
                this.Close();
            }
            catch (AuthenticationFailedException ex)
            {
                _client?.Dispose();
                DetailedMessageBox.Show(this, ex.Message, "Log in error", ex.FullResponse, MessageBoxImage.Error);
                return;
            }
            catch (SmtpException ex)
            {
                _client?.Dispose();
                DetailedMessageBox.Show(this, ex.Message, "Smtp error", ex.FullResponse, MessageBoxImage.Error);
                return;
            }
            catch (FormatException)
            {
                _client?.Dispose();
                MessageBox.Show("Invalid email format!", "Email format error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            catch (Exception ex)
            {
                _client?.Dispose();
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
        }