/// <summary> /// Ask password from user /// </summary> /// <param name="client">SMTP client</param> /// <param name="mailerSettingsConfig">Mailer settings</param> /// <returns>True if password was set</returns> public static bool Execute(SmtpClient client, GrfExporterSettingsConfig grfExporterSettingsConfig) { MailAuthorisationDlg dlg = new MailAuthorisationDlg(); dlg.Owner = App.Current.MainWindow; dlg.WindowStartupLocation = WindowStartupLocation.CenterOwner; dlg.Server.Text = grfExporterSettingsConfig.ServerAddress; dlg.UserName.Text = grfExporterSettingsConfig.UserName; dlg.Password.Focus(); bool?res = dlg.ShowDialog(); if (res.Value == true) { client.Credentials = new NetworkCredential(dlg.UserName.Text, dlg.Password.Password); if (dlg.RememberPassword.IsChecked.Value) { grfExporterSettingsConfig.RememberPassword = true; grfExporterSettingsConfig.Password = dlg.Password.Password; } } return(res.Value); }
/// <summary> /// Mailer constructor /// </summary> /// <param name="mailerSettingsConfig">Mailer settings confuration</param> /// <param name="resources">Plugin resources</param> public Mailer(GrfExporterSettingsConfig grfExporterSettingsConfig) { _CreateSMTPClient(grfExporterSettingsConfig); if (!grfExporterSettingsConfig.RememberPassword) { bool passwordEntered = MailAuthorisationDlg.Execute(_client, grfExporterSettingsConfig); if (!passwordEntered) { throw new InvalidOperationException(Properties.Resources.CanceledByUser); } } ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(_ValidateServerCertificate); }
/// <summary> /// Ask password from user /// </summary> /// <param name="client">SMTP client</param> /// <param name="mailerSettingsConfig">Mailer settings</param> /// <returns>True if password was set</returns> public static bool Execute(SmtpClient client, GrfExporterSettingsConfig grfExporterSettingsConfig) { MailAuthorisationDlg dlg = new MailAuthorisationDlg(); dlg.Owner = App.Current.MainWindow; dlg.WindowStartupLocation = WindowStartupLocation.CenterOwner; dlg.Server.Text = grfExporterSettingsConfig.ServerAddress; dlg.UserName.Text = grfExporterSettingsConfig.UserName; dlg.Password.Focus(); bool? res = dlg.ShowDialog(); if (res.Value == true) { client.Credentials = new NetworkCredential(dlg.UserName.Text, dlg.Password.Password); if (dlg.RememberPassword.IsChecked.Value) { grfExporterSettingsConfig.RememberPassword = true; grfExporterSettingsConfig.Password = dlg.Password.Password; } } return res.Value; }