/// <summary> /// Exibe a caixa de configuração de email /// </summary> /// <param name="smtp">se passado será usadoa estas configurações como padrão</param> /// <returns></returns> public static SMTPConfigResult Show(SMTPConfigResult smtp = default(SMTPConfigResult)) { SMTPConfigResult result = smtp; frmSMTPConfig f = new frmSMTPConfig(); if(result.IsValid()) { f.Server = result.Server; f.Password = result.Password; f.EnableSSL = result.EnableSSL; f.Username = result.Username; f.Port = result.Port; } if(f.ShowDialog() == DialogResult.Cancel) result.Cancel = true; else { result.Server = f.Server; result.Password = f.Password; result.EnableSSL = f.EnableSSL; result.Username = f.Username; result.Port = f.Port; } f.Dispose(); f = null; return result; }
/// <summary> /// Salva as configurações do SMTP /// </summary> /// <param name="smtp">configurações que deverão ser salvas</param> internal static void SaveConfig(SMTPConfigResult smtp) { //------------------------------------------------------------------------- // Salvar os dados do SMTP //------------------------------------------------------------------------- Registry.SetValue("SMTP", "Server", smtp.Server); Registry.SetValue("SMTP", "Password", smtp.Password); Registry.SetValue("SMTP", "Username", smtp.Username); Registry.SetValue("SMTP", "EnableSSL", smtp.EnableSSL); Registry.SetValue("SMTP", "Port", smtp.Port); }
/// <summary> /// Retorna a configuração salva no registro. /// </summary> /// <returns></returns> public static SMTPConfigResult GetConfig() { SMTPConfigResult result = new SMTPConfigResult(); //------------------------------------------------------------------------- // Recuperar os dados do registro //------------------------------------------------------------------------- result.Server = Registry.GetValue<string>("SMTP", "Server", ""); result.Password = Registry.GetValue<string>("SMTP", "Password", ""); result.EnableSSL = Registry.GetValue<bool>("SMTP", "EnableSSL", false); result.Username = Registry.GetValue<string>("SMTP", "Username", ""); result.Port = Registry.GetValue<int>("SMTP", "Port", 0); return result; }