private bool SendStatusChangeEmail(RepairsTbl pRepair) { EmailCls _Email = new EmailCls(); EquipTypeTbl _EquipTypes = new EquipTypeTbl(); RepairStatusesTbl _RepairStatuses = new RepairStatusesTbl(); _Email.SetEmailTo(pRepair.ContactEmail); _Email.SetEmailSubject("Change to repair status - notification."); _Email.AddStrAndNewLineToBody("<b>Repair Status Change Notification</b>"); _Email.AddFormatToBody("Dear {0}, <br /><br />", pRepair.ContactName); _Email.AddFormatToBody("Please note that repair status of the {0}, serial number: {1}, has changed to <b>{2}</b>.<br /><br />", _EquipTypes.GetEquipName(pRepair._MachineTypeID), pRepair.MachineSerialNumber, _RepairStatuses.GetRepairStatusDesc(pRepair.RepairStatusID)); _Email.AddStrAndNewLineToBody("You are receiving this status update since your email address was assigned to the tracking of this repair.<br />"); _Email.AddStrAndNewLineToBody("Please note that Quaffee DOES NOT run a coffee machine repair workshop. As a service to our current coffee " + "purchasing clients we will take the coffee machine to the workshop, give a swop out machine to the client, if available, and " + "charge what we are charged by the workshop plus a small admin fee. Please note: we are not able to quote these repairs, if you would like " + "to contact the workshop directly, please ask us for their details.<br />"); _Email.AddStrAndNewLineToBody("For clients that are not currently using our coffee, or have not used our coffee consistently over" + " the last 3 months, we may at our discretion offer a swop out machine, at a fee, and also change a collection and delivery fee.<br />"); _Email.AddStrAndNewLineToBody("Any warantee on the repairs is carried by the workshop not by Quaffee.<br />"); _Email.AddStrAndNewLineToBody("The Quaffee Team"); _Email.AddStrAndNewLineToBody("web: <a href='http://www.quaffee.co.za'>quaffee.co.za</a>"); return(_Email.SendEmail()); }
private void DisableCustomerTracking(string pCustID) { int _CustID; if (Int32.TryParse(pCustID, out _CustID)) { string _CCEmail = (ConfigurationManager.AppSettings[EmailCls.CONST_APPSETTING_FROMEMAILKEY] == null) ? "*****@*****.**" : ConfigurationManager.AppSettings[EmailCls.CONST_APPSETTING_FROMEMAILKEY]; TrackerDotNet.control.CustomersTbl _Customers = new control.CustomersTbl(); _Customers.DisableCustomer(_CustID); _Customers = _Customers.GetCustomersByCustomerID(_CustID); CompanyNameLabel.Text = _Customers.CompanyName; string _Name = String.Empty; _Name = _Customers.ContactAltFirstName; if (!String.IsNullOrEmpty(_Name)) { if (!String.IsNullOrEmpty(_Customers.ContactAltFirstName)) { _Name += " & " + _Customers.ContactAltFirstName; } } else if (!String.IsNullOrEmpty(_Customers.ContactAltFirstName)) { _Name = _Customers.ContactAltFirstName; } else { _Name = "X Coffee lover"; } EmailCls _Email = new EmailCls(); if (!String.IsNullOrEmpty(_Customers.EmailAddress)) { _Email.SetEmailTo(_Customers.EmailAddress); } if (!String.IsNullOrEmpty(_Customers.AltEmailAddress)) { _Email.SetEmailTo(_Customers.AltEmailAddress); } _Email.SetEmailCC(_CCEmail); _Email.SetEmailSubject(_Customers.CompanyName + " request to be disabled in Coffee Tracker"); _Email.AddFormatToBody("Dear {0}, <br /><br />", _Name); _Email.AddFormatToBody("As requested we have disabled: {0} in Quaffee's Coffee Tracker.<br /><br />", _Customers.CompanyName); _Email.AddFormatToBody("We wish you the best in the future. Should you require anything else from us please email {0}.<br /><br />", _CCEmail); _Email.AddStrAndNewLineToBody("The Quaffee Orders Team"); _Email.AddStrAndNewLineToBody("web: <a href='http://www.quaffee.co.za'>quaffee.co.za</a>"); _Email.SendEmail(); } else { CompanyNameLabel.Text = "Company not found"; } }
private bool SendDeliveredEmail(long pCustomerID, string pMessage) { bool _Success = false; CustomersTbl _CT = new CustomersTbl(); _CT = _CT.GetCustomersByCustomerID(pCustomerID); if ((_CT.EmailAddress.Contains("@")) || (_CT.AltEmailAddress.Contains("@"))) { string _Name = String.Empty; EmailCls _Email = new EmailCls(); _Email.SetEmailSubject("Confirmation email"); if (_CT.EmailAddress.Contains("@")) { _Email.SetEmailTo(_CT.EmailAddress); if (_CT.AltEmailAddress.Contains("@")) { _Email.SetEmailCC(_CT.AltEmailAddress); _Name = (!String.IsNullOrEmpty(_CT.ContactFirstName)) ? _CT.ContactFirstName : String.Empty; if ((!String.IsNullOrEmpty(_Name)) && (!String.IsNullOrEmpty(_CT.ContactAltFirstName))) { _Name += " and "; } _Name += (String.IsNullOrEmpty(_CT.ContactAltFirstName)) ? _CT.ContactAltFirstName : String.Empty; } else { _Email.SetEmailTo(_CT.AltEmailAddress); _Name += (String.IsNullOrEmpty(_CT.ContactAltFirstName)) ? _CT.ContactAltFirstName : String.Empty; } } else // null first email { _Email.SetEmailTo(_CT.AltEmailAddress); _Name += (String.IsNullOrEmpty(_CT.ContactAltFirstName)) ? _CT.ContactAltFirstName : String.Empty; } if (String.IsNullOrEmpty(_Name)) { _Name = "coffee lover"; } _Email.AddFormatToBody("To {0},<br />,<br />", _Name); _Email.AddStrAndNewLineToBody("Just a quick note to notify you that Quaffee has " + pMessage + "<br />"); _Email.AddStrAndNewLineToBody("Thank you for your support.<br />"); _Email.AddStrAndNewLineToBody("Sincerely Quaffee Team ([email protected])"); _Success = _Email.SendEmail(); } return(_Success); }
/// <summary> /// Send email to the current client to confirm the items in the current order, and the deliver date /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnConfirmOrder_Click(object sender, EventArgs e) { DropDownList _ddlThisContact = (DropDownList)dvOrderHeader.FindControl("ddlContacts"); ContactEmailDetails _thisContact = GetEmailDetails(_ddlThisContact.SelectedItem.Value); if (_thisContact != null) { EmailCls _email = new EmailCls(); DropDownList _ddlDeliveryBy = (DropDownList)dvOrderHeader.FindControl("ddlToBeDeliveredBy"); // who is delivering this string _DeliveryDate = dvOrderHeaderGetLabelValue("lblRequiredByDate"); // date it will be dispatched / delivered" string _PurchaseOrder = dvOrderHeaderGetLabelValue("lblPurchaseOrder"); string _Notes = dvOrderHeaderGetLabelValue("lblNotes"); if (_thisContact.EmailAddress != "") { _email.SetEmailFromTo(CONST_FROMEMAIL, _thisContact.EmailAddress); if (_thisContact.altEmailAddress != "") { _email.SetEmailCC(_thisContact.altEmailAddress); } } else if (_thisContact.altEmailAddress != "") { _email.SetEmailFromTo(CONST_FROMEMAIL, _thisContact.altEmailAddress); } else { ltrlStatus.Text = "no email address found"; TrackerDotNet.classes.showMessageBox _NoMsgBx = new classes.showMessageBox(this.Page, "Email FAILED: ", ltrlStatus.Text); upnlNewOrderItem.Update(); return; // no email address so quit } // send a BCC to orders to confirm _email.SetEmailBCC(CONST_FROMEMAIL); // set subject and body _email.SetEmailSubject("Order Confirmation"); string _AddressedTo = "Coffee Lover"; if (_thisContact.FirstName != "") { _AddressedTo = _thisContact.FirstName.Trim(); if (_thisContact.altFirstName != "") { _AddressedTo += " and " + _thisContact.altFirstName.Trim(); } } else if (_thisContact.altFirstName != "") { _AddressedTo = _thisContact.altFirstName.Trim(); } _email.AddStrAndNewLineToBody("Dear " + _AddressedTo + ",<br />"); if (_ddlThisContact.SelectedValue.Equals(NewOrderDetail.CONST_ZZNAME_DEFAULTID)) { _email.AddStrAndNewLineToBody("We confirm you order below:"); } else { _email.AddStrAndNewLineToBody("We confirm the following order for " + _ddlThisContact.SelectedItem.Text + ":"); } _email.AddToBody("<ul>"); foreach (GridViewRow _gv in gvOrderLines.Rows) { DropDownList _gvItemDLL = (DropDownList)_gv.FindControl("ddlItemDesc"); Label _gvItemQty = (Label)_gv.FindControl("lblQuantityOrdered"); DropDownList _gvItemPackaging = (DropDownList)_gv.FindControl("ddlPackaging"); // need to check for serivce / note and add the note using the same logic as we have for the delivery sheet if (GetItemSortOrderID(_gvItemDLL.SelectedValue) == ItemTypeTbl.CONST_NEEDDESCRIPTION_SORT_ORDER) { // if we are already use the notes field for name, check if there is a ":" seperator, and then only use what is after if (_Notes.Contains(":")) { _Notes = _Notes.Substring(_Notes.IndexOf(":") + 1).Trim(); } int _Start = _Notes.IndexOf(OrderDetail.CONST_EMAILDELIMITERSTART); if (_Start >= 0) { int _End = _Notes.IndexOf(OrderDetail.CONST_EMAILDELIMITEREND); if (_End >= 0) { _Notes = String.Concat(_Notes.Substring(0, _Start), ";", _Notes.Substring(_End + 2)); } } _email.AddFormatToBody("<li>{0}</li>", _Notes); } else { string _UnitsAndQty = AddUnitsToQty(_gvItemDLL.SelectedValue, _gvItemQty.Text); if (_gvItemPackaging.SelectedIndex == 0) { _email.AddFormatToBody("<li>{0} of {1}</li>", _UnitsAndQty, _gvItemDLL.SelectedItem.Text); } else { _email.AddFormatToBody("<li>{0} of {1} - Preperation note: {2}</li>", _UnitsAndQty, _gvItemDLL.SelectedItem.Text, _gvItemPackaging.SelectedItem.Text); } } } _email.AddStrAndNewLineToBody("</ul>"); if (!string.IsNullOrEmpty(_PurchaseOrder)) { if (_PurchaseOrder.EndsWith(TrackerTools.CONST_POREQUIRED)) { _email.AddStrAndNewLineToBody("<b>NOTE</b>: We are still waiting for a Purchase Order number from you.<br />"); } else { _email.AddStrAndNewLineToBody(string.Format("This order has purchase order: {0}, allocated to it.<br />", _PurchaseOrder)); } } if (_ddlDeliveryBy.SelectedItem.Text == CONST_DELIVERYTYPEISCOLLECTION) { _email.AddStrAndNewLineToBody("The order will be ready for collection on: " + _DeliveryDate); } else if (_ddlDeliveryBy.SelectedItem.Text == CONST_DELIVERYTYPEISCOURIER) { _email.AddStrAndNewLineToBody("The order will be dispatched on: " + _DeliveryDate + "."); } else { _email.AddStrAndNewLineToBody("The order will be delivered on: " + _DeliveryDate + "."); } // Add a footer MembershipUser _currMember = Membership.GetUser(); string _from = string.IsNullOrEmpty(_currMember.UserName) ? "the Quaffee Team" : " from the Quaffee Team (" + UpCaseFirstLetter(_currMember.UserName) + ")"; _email.AddStrAndNewLineToBody("<br />Sent automatically by Quaffee's order and tracking System.<br /><br />Sincerely " + _from + " ([email protected])"); if (_email.SendEmail()) { ltrlStatus.Text = "Email Sent to: " + _AddressedTo; } else { showMessageBox _msg = new showMessageBox(this.Page, "error", "error sending email: " + _email.myResults); ltrlStatus.Text = "Email was not sent!"; } TrackerDotNet.classes.showMessageBox _MsgBx = new classes.showMessageBox(this.Page, "Email Confirmation", ltrlStatus.Text); upnlNewOrderItem.Update(); } }
/// <summary> /// Send email to the current client to confirm the items in the current order, and the deliver date /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnConfirmOrder_Click(object sender, EventArgs e) { DropDownList _ddlThisContact = (DropDownList)dvOrderHeader.FindControl("ddlContacts"); ContactDetails.ContactEmailDetails _thisContact = GetContactsEmailDetails(_ddlThisContact.SelectedItem.Value); if (_thisContact != null) { EmailCls _email = new EmailCls(); DropDownList _ddlDeliveryBy = (DropDownList)dvOrderHeader.FindControl("ddlToBeDeliveredBy"); // who is delivering this Label _lblDeliveryDate = (Label)dvOrderHeader.FindControl("lblRequiredByDate"); // date it will be dispatched / delivered" if (_thisContact.EmailAddress != "") { _email.SetEmailFromTo(CONST_FROMEMAIL, _thisContact.EmailAddress); if (_thisContact.altEmailAddress != "") { _email.SetEmailCC(_thisContact.altEmailAddress); } } else if (_thisContact.altEmailAddress != "") { _email.SetEmailFromTo(CONST_FROMEMAIL, _thisContact.altEmailAddress); } else { return; // no email address so quit } // send a BCC to orders to confirm _email.SetEmailBCC(CONST_FROMEMAIL); // set subject and body _email.SetEmailSubject("Order Confirmation"); _email.AddStrAndNewLineToBody("Dear " + ((_thisContact.FirstName != "") ? _thisContact.FirstName : ((_thisContact.altFirstName != "") ? _thisContact.altFirstName : "Coffee Lover")) + ",<br />"); _email.AddStrAndNewLineToBody("We confirm the following order for " + _ddlThisContact.SelectedItem.Text + ":"); _email.AddToBody("<ul>"); foreach (GridViewRow _gv in gvOrderLines.Rows) { DropDownList _gvItemDesc = (DropDownList)_gv.FindControl("ddlItemDesc"); Label _gvItemQty = (Label)_gv.FindControl("lblQuantityOrdered"); DropDownList _gvItemPackaging = (DropDownList)_gv.FindControl("ddlPackaging"); // need to check for serivce / note and add the note using the same logic as we have for the delivery sheet if (_gvItemPackaging.SelectedIndex == 0) { _email.AddFormatToBody("<li>{0} x {1}</li>", _gvItemQty.Text, _gvItemDesc.SelectedItem.Text); } else { _email.AddFormatToBody("<li>{0} x {1} - Preperation note: {2}</li>", _gvItemQty.Text, _gvItemDesc.SelectedItem.Text, _gvItemPackaging.SelectedItem.Text); } } _email.AddStrAndNewLineToBody("</ul>"); if (_ddlDeliveryBy.SelectedItem.Text == CONST_DELIVERYTYPEISCOLLECTION) { _email.AddStrAndNewLineToBody("Will be ready for collection on: " + _lblDeliveryDate.Text); } else if (_ddlDeliveryBy.SelectedItem.Text == CONST_DELIVERYTYPEISCOURIER) { _email.AddStrAndNewLineToBody("Will be dispatched on: " + _lblDeliveryDate.Text + "."); } else { _email.AddStrAndNewLineToBody("Will be delivered on: " + _lblDeliveryDate.Text + "."); } // Add a footer _email.AddStrAndNewLineToBody("<br />Sent automatically by Quaffee's order and tracking System.<br /><br />Sincerely Quaffee Team ([email protected])"); if (_email.SendEmail()) { ltrlStatus.Text = "Email Sent to: " + _thisContact.EmailAddress; } else { ltrlStatus.Text = "Email was not sent!"; } } }
bool SendReminder(SendCheckEmailTextsData pEmailTextData, ContactToRemindWithItems pContact, string pOrderType) #endif { const string CONST_SERVERURL = "http://tracker.quaffee.co.za/QonT/"; const string CONST_HTMLBREAK = "<br /><br />"; const string CONST_ADDORDERURL = "Internal: Order Ref <a href='" + CONST_SERVERURL + "{0}'>here</a>."; const string CONST_DISABLECUSTOMERURL = "If you would prefer to be disabled then click <a href='" + CONST_SERVERURL + "DisableClient.aspx?CoID={0}'>disable me</a>"; bool _ReminderSent = false; bool _HasAutoFulfilElements = false, _HasReoccuringElements = false, _HadError = false; SentRemindersLogTbl _ReminderLog = new SentRemindersLogTbl(); #region CreateAndPopulateUsageSummaryTable string _EmailBodyTable = UsageSummaryTableHeader(pContact); string _OrderType = (String.IsNullOrEmpty(pOrderType)) ? "a reminder only" : pOrderType; // send a reminder // build up Table _EmailBodyTable += String.Format(CONST_SUMMARYTABLEHEADER, "Company/Contact", pContact.CompanyName); _EmailBodyTable += String.Format(CONST_SUMMARYTABLBODYROW2COL, "Next estimate prep date", String.Format("{0:d MMM, ddd}", pContact.NextPrepDate)); _EmailBodyTable += String.Format(CONST_SUMMARYTABLBODYALTROW2COL, "Next estimate dispatch date", String.Format("{0:d MMM, ddd}", pContact.NextDeliveryDate)); _EmailBodyTable += String.Format(CONST_SUMMARYTABLBODYALTROW2COL, "Type", _OrderType); if (pContact.ItemsContactRequires.Count > 0) { _EmailBodyTable += String.Format(CONST_SUMMARYTABLBODYROW3COL, "<b>List of Items</b>"); for (int j = 0; j < pContact.ItemsContactRequires.Count; j++) { _EmailBodyTable += CONST_SUMMARYTABLEBODYROWSTART + AddLastOrderTableRow(pContact.ItemsContactRequires[j], (j % 2 == 0)) + CONST_SUMMARYTABLEBODYROWEND; } } _EmailBodyTable += CONST_SUMMARYTABLEBODYEND; #endregion // add to orders if it is a autofulful or #region AddOrderLines if (!String.IsNullOrWhiteSpace(pOrderType)) { OrderTblData _OrderData = new OrderTblData(); _HasAutoFulfilElements = true; _OrderData.CustomerId = pContact.CustomerID; _OrderData.OrderDate = DateTime.Now.Date; _OrderData.RoastDate = pContact.NextPrepDate.Date; _OrderData.RequiredByDate = pContact.NextDeliveryDate.Date; _OrderData.ToBeDeliveredBy = (pContact.PreferedAgentID < 0) ? TrackerTools.CONST_DEFAULT_DELIVERYBYID : pContact.PreferedAgentID; // the prefered person is the delivery agent _OrderData.Confirmed = false; // we have not confirmed the order, it is a reoccuring or auto order _OrderData.InvoiceDone = false; // we have not confirmed the order, it is a reoccuring or auto order _OrderData.PurchaseOrder = string.Empty; // we have not confirmed the order, it is a reoccuring or auto order _OrderData.Notes = pOrderType; ReoccuringOrderDAL _Reoccur = new ReoccuringOrderDAL(); // to set the last date OrderTbl _OrderTbl = new OrderTbl(); string _InsertErr = String.Empty; int j = 0; // insert each itm that is Reoccuing or auto while ((j < pContact.ItemsContactRequires.Count) && String.IsNullOrEmpty(_InsertErr)) { _OrderData.ItemTypeID = pContact.ItemsContactRequires[j].ItemID; _OrderData.QuantityOrdered = pContact.ItemsContactRequires[j].ItemQty; _OrderData.PackagingID = pContact.ItemsContactRequires[j].ItemPackagID; _OrderData.PrepTypeID = pContact.ItemsContactRequires[j].ItemPrepID; _InsertErr = _OrderTbl.InsertNewOrderLine(_OrderData); // mark a reoccuring item as done with the current prep date if (pContact.ItemsContactRequires[j].ReoccurOrder) { _Reoccur.SetReoccuringOrdersLastDate(pContact.NextPrepDate, pContact.ItemsContactRequires[j].ReoccurID); _HasReoccuringElements = true; } j++; } // add a record into the log to say it was sent _HadError = !String.IsNullOrEmpty(_InsertErr); if (_HadError) { showMessageBox _MsgBox = new showMessageBox(this.Page, "Error Inserting order for :" + pContact.CompanyName, _InsertErr); } else { pEmailTextData.Footer += CONST_HTMLBREAK + "Items added to orders."; } } else /// we are not autoadding so lets append a "LastOrder Equiv to the message" { string _AddOrder = String.Format("Pages/NewOrderDetail.aspx?Z&{0}={1}", NewOrderDetail.CONST_URL_REQUEST_CUSTOMERID, pContact.CustomerID); for (int j = 0; j < pContact.ItemsContactRequires.Count; j++) { _AddOrder += String.Format("&SKU{0}={1}&SKUQty{2}={3}", j + 1, GetItemSKU(pContact.ItemsContactRequires[j].ItemID), j + 1, pContact.ItemsContactRequires[j].ItemQty); } pEmailTextData.Footer += CONST_HTMLBREAK + String.Format(CONST_ADDORDERURL, _AddOrder); pEmailTextData.Footer += CONST_HTMLBREAK + String.Format(CONST_DISABLECUSTOMERURL, pContact.CustomerID); } #endregion #if _DEBUG pContact.EmailAddress = "*****@*****.**"; pContact.AltEmailAddress = ""; #endif #region SendEmail string _FromEmail = ConfigurationManager.AppSettings[EmailCls.CONST_APPSETTING_FROMEMAILKEY]; string _Greetings = String.Empty; EmailCls _Email = new EmailCls(); _Email.SetEmailFrom(_FromEmail); _Email.SetEmailSubject(tbxEmailSubject.Text); if (pContact.EmailAddress.Contains("@")) { _Email.SetEmailTo(pContact.EmailAddress, true); _Greetings = String.IsNullOrWhiteSpace(pContact.ContactFirstName) ? "<p>Hi Coffee Lover,</p>" : "<p>Hi " + pContact.ContactFirstName + ",</p>"; _Email.MsgBody = _Greetings + "<p>" + pEmailTextData.Header + "</p><p>" + pEmailTextData.Body + "</p><br />" + _EmailBodyTable + "<br /><br />" + pEmailTextData.Footer; #if _DEBUG _ReminderSent = true; //if ((pReminderCount < 5) || (!String.IsNullOrWhiteSpace(pOrderType))) // _ReminderSent = _Email.SendEmail(); //else // _ReminderSent = true; #else _ReminderSent = _Email.SendEmail(); #endif } if (pContact.AltEmailAddress.Contains("@")) { _Email.SetEmailTo(pContact.AltEmailAddress, true); _Greetings = String.IsNullOrWhiteSpace(pContact.ContactAltFirstName) ? "<p>Hi Coffee Lover,</p>" : "<p>Hi " + pContact.ContactAltFirstName + ",</p>"; _Email.MsgBody = _Greetings + "<p>" + pEmailTextData.Header + "</p><p>" + pEmailTextData.Body + "</p><br />" + _EmailBodyTable + CONST_HTMLBREAK + pEmailTextData.Footer; #if _DEBUG _ReminderSent = true; #else _ReminderSent = (_ReminderSent) || (_Email.SendEmail()); #endif } #endregion /// cipy values across and add to database _ReminderLog.CustomerID = pContact.CustomerID; _ReminderLog.DateSentReminder = System.DateTime.Now.Date; _ReminderLog.NextPrepDate = pContact.NextCoffee.Date; // use the coffee date _ReminderLog.ReminderSent = _ReminderSent; _ReminderLog.HadAutoFulfilItem = _HasAutoFulfilElements; _ReminderLog.HadReoccurItems = _HasReoccuringElements; _ReminderLog.InsertLogItem(_ReminderLog); return(_ReminderSent); }