private void buttonEmail_Click(object sender, EventArgs e) { try { foreach (ListViewItem item in listView.SelectedItems) { int id = Convert.ToInt16(item.Tag); Invoice invoice = new Invoice(id); if (!invoice.Customer.EmailAddress.Equals("")) { Email email = new Email(); if (email.Send(invoice.Customer.EmailAddress, invoice.Customer.Name, "MeulenFoods Invoice " + invoice.Id, invoice.HTMLEmail)) { Tools.ShowInfo("Invoice email sent to " + invoice.Customer.Name + " [" + invoice.Customer.EmailAddress + "]"); } else { Tools.ShowError(email.ErrorMessage); } } else { Tools.ShowInfo("Customer does not have a email address, update the customer email address first."); } } } catch (Exception ex) { Tools.ShowError("Unable to load invoice to perform email\n" + ex.Message); } }
private void buttonEmail_Click(object sender, EventArgs e) { Email email = new Email(); Statement statement = getStatement(); DateTime enddate = DateTime.Now; DateTime begindate = DateTime.Now.AddMonths(-1); begindate = new DateTime(begindate.Year, begindate.Month, 1); if (radioButtonDateRange.Checked) { begindate = dateTimePickerStart.Value; enddate = dateTimePickerEnd.Value; } if (email.Send(this.customer.EmailAddress, this.customer.Name, "MeulenFoods Statement: " + begindate.ToShortDateString() + "-" + enddate.ToShortDateString(), statement.EmailHTML)) { Tools.ShowInfo("Statement email sent to " + this.customer.Name + " [" + this.customer.EmailAddress + "]"); } else { Tools.ShowError(email.ErrorMessage); } }
private void buttonEmail_Click(object sender, EventArgs e) { try { foreach (ListViewItem item in listView.SelectedItems) { int id = Convert.ToInt16(item.Tag); Customer customer = new Customer(id); if (!customer.EmailAddress.Equals("")) { DateTime enddate = DateTime.Now; DateTime begindate = DateTime.Now.AddMonths(-1); begindate = new DateTime(begindate.Year, begindate.Month, 1); Statement statement = new Statement(customer, true, begindate, enddate); Email email = new Email(); if (email.Send(customer.EmailAddress, customer.Name, "MeulenFoods Statement: " + begindate.ToShortDateString() + "-" + enddate.ToShortDateString(), statement.EmailHTML)) { Tools.ShowInfo("Statement email sent to " + customer.Name + " [" + customer.EmailAddress + "]"); } else { Tools.ShowError(email.ErrorMessage); } } else { Tools.ShowInfo("Customer does not have a email address, update the customer email address first."); } } } catch (Exception ex) { Tools.ShowError("Unable to load customer\n" + ex.Message); } }