public EmailWindow(Email email)
        {
            InitializeComponent();
            this.Email = email;
            if (Email == null) return;

            FromAddress = email.FromAddress.Address;
            Password = email.FromPassword;
            To = email.ToAddress.Address;
            Subject = email.Subject;
            Body = email.Body;
            Smtp = email.Smtpclient.Host;
            Port = email.PortNum;
        }
        void EmailSettingButton_Click(object sender, RoutedEventArgs e)
        {
            var emailSetting = new EmailWindow(_email);

            bool? ok = emailSetting.ShowDialog();
            if (ok != null && ok == true)
            {
                _email = emailSetting.Email;
            }
        }
 private void OkButton_OnClick(object sender, RoutedEventArgs e)
 {
     DialogResult = true;
     if (IsValidEmail(FromAddress) && IsValidEmail(To))
     {
         Email = new Email(FromAddress, Password, To,
             Subject, Body, Port);
         Email.CreateSmtpClient(Smtp);
         Close();
     }
     else
         MessageBox.Show("Invalid e-mail format");  
 }