private void bTestSMTP_Click(object sender, EventArgs e) { int port = 25; try { port = Convert.ToInt32(tbSMTPPort.Text); if (port != Convert.ToDouble(tbSMTPPort.Text)) { throw new Exception("Must be an integer."); } if (port < 0 || port > 65535) { throw new Exception("Must be between 0 and 65535"); } } catch { MessageBox.Show("Port must be an integer between 0 and 65535.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); tbSMTPPort.Focus(); tbSMTPPort.SelectAll(); return; } if (tbPassword.Text != tbConfirmPassword.Text) { MessageBox.Show("The passwords do not match.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); tbConfirmPassword.Clear(); tbPassword.Clear(); tbPassword.Focus(); tbPassword.SelectAll(); return; } if (!Regex.IsMatch(tbFromAddress.Text, @"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*")) { MessageBox.Show("From address is not a valid email address.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); tbFromAddress.Focus(); tbFromAddress.SelectAll(); return; } try { ReadDir.SendMail(tbSMTPAddress.Text, port, cbSSL.Checked, tbUsername.Text, tbPassword.Text, tbFromAddress.Text, tbFromName.Text, "ReadMe Test", "This email is to test the smtp server", cbHTML.Checked, new string[] { tbFromAddress.Text }, new string[] { }); MessageBox.Show("Test Successful", "Success", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void InitializeIDirs() { XmlDocument xDoc = XMLDoc(); XmlNodeList inputs = xDoc.GetElementsByTagName("input"); iDirs = new ReadDir[inputs.Count]; int count = 0; foreach (XmlNode input in inputs) { iDirs[count] = new ReadDir(input.Attributes.GetNamedItem("dir").Value); XmlNodeList outputs = input.ChildNodes; foreach (XmlNode output in outputs) { iDirs[count].AddOutputDirectory(output.Attributes.GetNamedItem("dir").Value, output.Attributes.GetNamedItem("type").Value, (output.Attributes.GetNamedItem("email").Value == "true")); } count++; } }