private void SaveSettings(CancelEventArgs e) { DialogResult dr = MessageBox.Show("确定保存修改?", "确定", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { // 获取产品基本信息 string host = txtHost.Text.Trim(); int port = int.Parse(txtPort.Text.Trim()); bool enableSSL = cbEnableSSL.Checked; string address = txtAddress.Text.Trim(); string password = txtPassword.Text; int timeout = int.Parse(numTimeout.Value.ToString()); string displayName = txtDisplayName.Text; MailPriority priority = MailPriority.Normal; if (rdPrioNormal.Checked) { priority = MailPriority.Normal; } else if (rdPrioLow.Checked) { priority = MailPriority.Low; } else if (rdPrioHigh.Checked) { priority = MailPriority.High; } string tailContent = txtTailContent.Text.Replace(System.Environment.NewLine, "\n"); int sendInterval = int.Parse(txtSendInterval.Text.Trim()); // 重新生成内存对象 Manager.MailSender = new MailSender(host, port, enableSSL, address, password, timeout, displayName, priority, tailContent, sendInterval); // 写数据库 MailSenderStorage.WriteMailSender(Manager.MailSender); MessageBox.Show("保存完成!"); } else { e.Cancel = true; } }
public void ReloadMailSender() { _mailSender = MailSenderStorage.ReadMailSender(); // 读取发件人信息 }