public static bool Initialize(string storePath, INotifier notifier) { bool success = true; if (Instance == null) { BackingStorePath = string.Format(@"{0}\{1}", storePath, "CampfireInfo.xml"); Instance = Restore(BackingStorePath); if (Instance == null) { // Data in the xml file was corrupt/unreadable success = false; Instance = new CampfireState(); } if (notifier == null) { notifier = new Notifier(); } Instance.Notifier = notifier; } return success; }
private void SendTestEmailButton_Click(object sender, EventArgs e) { int top = this.Bounds.Top; int right = this.Bounds.Right; if (!((bool)HostnameTextBox.Tag) || !((bool)PortTextBox.Tag)) { MessageBox.Show("A valid Hostname and Port are required, at a minimum, to send a test email"); return; } string emailAddr = Microsoft.VisualBasic.Interaction.InputBox( "Enter \"To\" email addr. A test email will be sent, verifying that your email configuration is working.", "Test email", "", right - 70, top + 130); if (string.IsNullOrEmpty(emailAddr)) { MessageBox.Show("No test email was sent."); return; } if (!Utils.IsValidEmail(emailAddr)) { MessageBox.Show(string.Format("\"{0}\" is an invalid email address. No test email was sent.", emailAddr)); return; } try { using (ChangeCursor cc = new ChangeCursor(Cursors.WaitCursor)) { Notifier mailer = new Notifier(); int port = 0; Int32.TryParse(PortTextBox.Text, out port); mailer.SentTestEmail(emailAddr, FromTextBox.Text, HostnameTextBox.Text, port, UsernameTextBox.Text, PasswordTextBox.Text, DefaultCredsCheckBox.Checked, SendWelcomeEmailCheckBox.Checked ? ExtraEmailMessage.Text : null); } MessageBox.Show("Mail was successfully sent, please check your InBox"); } catch (InvalidOperationException ex) { MessageBox.Show(string.Format("Sending mail failed. Exception: {0}, Message: {1}", ex.GetType().ToString(), ex.Message)); } catch (SmtpException ex) { MessageBox.Show(string.Format("Sending mail failed. Exception: {0}, Message: {1}", ex.GetType().ToString(), ex.Message)); } }