private void button2_Click(object sender, EventArgs e) { try { SaveData(); UpdateCore.Email em = UpdateCore.Email.Instance; bool sucess = em.SendEmail("Test Email", "This is a test email to check that your email is configured corectly for the Windows Update application. Check your inbox and if you received this email then all is ok"); SaveData(); MessageBox.Show("An email has been sent to your inbox as a test"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void TestEmailSend() { Init(); // For stand alone unit testing Database db = new Database(); string SQL = "SELECT SmtpHost, SmtpPort, FromEmailAddress, FromEmailDisplayName, FromPassword, DefaultSendEmail FROM dbo.[CONFIG]"; List <string> rows = db.Read(SQL, 6); string[] cols = rows[0].Split(new Database().COLUMN_DELIMETER); UpdateCore.Email email = UpdateCore.Email.Instance; email.SmtpHost = cols[0]; email.setSmtpPort(Int32.Parse(cols[1])); email.FromEmailAddress = cols[2]; email.FromEmailDisplayName = cols[3]; email.FromPassword = cols[4]; email.SendEmail(cols[5], "This is a test email", "The body of this email is blank"); }