private void btnSend_Click(object sender, EventArgs e) { try { string email = tbEmail.Text; string subject = tbSubject.Text; string note = tbNote.Text; if (tmrAllowMail.Enabled) { RemindMeBox.Show("You have recently sent an e-mail. Wait a bit before you do it again!"); return; } if (!string.IsNullOrWhiteSpace(subject) && !string.IsNullOrWhiteSpace(note)) { lblSending.Visible = true; pbSending.Visible = true; btnSend.Enabled = false; // TimeSpan timeout = TimeSpan.FromSeconds(5); if (string.IsNullOrWhiteSpace(email)) { sendMailThread = new Thread(() => sendMailException = BLEmail.SendEmail(subject, note, false)); } else { try { MailMessage mes = new MailMessage(email, "*****@*****.**", subject, note); sendMailThread = new Thread(() => sendMailException = BLEmail.SendEmail(subject, note, email, false)); } catch (FormatException ex) { btnSend.Enabled = true; lblSending.Visible = false; pbSending.Visible = false; RemindMeBox.Show("Please enter a valid e-mail address, or leave it empty"); } } if (sendMailThread != null) { sendMailThread.Start(); tmrSendMail.Start(); tbEmail.ResetText(); tbNote.ResetText(); tbSubject.ResetText(); } } } catch (Exception ex) { MessageFormManager.MakeMessagePopup("Something went wrong. Could not send the e-mail", 3); } }
// Handles submission of admin registration form protected void btnSubmit_Click(object sender, EventArgs e) { if (IsValid) { string password = BLPassword.RandomString(10, true); string mailbody = "<p>" + "Hi," + "</p>" + "<p>" + "Below is the verification link needed to update your password (click to update):" + "</p>" + "<p>" + "https://localhost:44326/UL/ChangePassword/" + tbxUsername.Text + "/" + password + "</p>" + "<br/>" + "<p>" + "Kind Regards," + "</p>" + "<p>" + "The JerseySure Team" + "</p>"; try { BLEmail.SendEmail(tbxUsername.Text, "Admin Verification Link - JerseySure", mailbody); } catch (Exception ex) { Response.Redirect("~/UL/ErrorPage/1"); } BLUser newUser = new BLUser { userFirstName = tbxFirstName.Text, userLastName = tbxLastName.Text, userEmail = tbxUsername.Text, userPhone = tbxPhone.Text, billAddress = null, postAddress = BLAddress.fillAddress('P', tbxAddress.Text, tbxSuburb.Text, ddlState.SelectedValue, Convert.ToInt32(tbxPostCode.Text)), userPassword = password, userAdmin = true, userActive = true }; // Add admin account BLUser.addUser(newUser); // View saying verification email has been sent Response.Redirect("~/UL/SuccessPage/0"); } }
public IHttpActionResult emailprueba(int id) { try { string email = TokenInfo.getClaim(Request, "email"); BLPaquete bl = new BLPaquete(); return(Ok(BLEmail.actualizacionEstado(bl.getPaquete(id)))); } catch (Exception e) { return(Content(HttpStatusCode.InternalServerError, e.Message)); } }
protected void RequestButton_Click(object sender, EventArgs e) { if (IsValid) { // Check if email exists in the system; reload page and display error if not -- X // If exists, update password to random generated string; password is hashed for security string randomCode = BLPassword.RandomString(10, true); // Retrieve user corresponding to email address of account and update password BLUser user = new BLUser(); user = user.getUserByEmail(EmailTextBox.Text); BLUser.updateUserPassword(user, randomCode); // Attach email address and hashed password as parameters for url to update password (sent in the email) string mailbody = "<p>" + "Hi," + "</p>" + "<p>" + "Below is the verification link needed to update your password (click to update):" + "</p>" + "<p>" + "https://localhost:44326/UL/ChangePassword/" + EmailTextBox.Text + "/" + randomCode + "</p>" + "<br/>" + "<p>" + "Kind Regards," + "</p>" + "<p>" + "The JerseySure Team" + "</p>"; try { BLEmail.SendEmail(EmailTextBox.Text, "Verification Link - JerseySure", mailbody); } catch (Exception ex) { // Display error page for unable to send email Response.Redirect("~/UL/ErrorPage/1"); } // Display success status of email being sent Response.Redirect("~/UL/SuccessPage/0"); } }
protected void Page_Load(object sender, EventArgs e) { // Check for secure connection if (Request.IsSecureConnection) { // Page only accessible to a logged in user if (Session["LoginStatus"].Equals("User")) { // Check if items are still in the cart - otherwise; wrong state BLShoppingCart cart = Session["Cart"] as BLShoppingCart; if (!cart.isEmpty()) { // Send confirmation of order to account email address BLShipping shipping = Session["Shipping"] as BLShipping; string mailbody = BLPurchase.generateOrderSummary(Session["Name"].ToString(), cart, shipping); try { BLEmail.SendEmail(Session["UserName"].ToString(), "Order Receipt - JerseySure", mailbody); } catch (Exception ex) { Response.Redirect("~/UL/ErrorPage/1"); } // Remove cart from session Session.Remove("Cart"); Session["Cart"] = new BLShoppingCart(); } else { Response.Redirect("~/UL/ErrorPage/7"); } } else { Response.Redirect("~/UL/ErrorPage/0"); } } else { // Make connection secure if it isn't already string url = ConfigurationManager.AppSettings["SecurePath"] + "PaymentConfirmation"; Response.Redirect(url); } }
// Redirect to contact enquiry received message protected void btnSubmit_Click(object sender, EventArgs e) { if (IsValid) { // Send email with query information // Generate message body for email string mailbody = "<p>" + tbxName.Text + "," + "</p>" + "<p>" + "This is a courtesy email to inform you that we have " + "received your enquiry and will respond within two business days." + "</p>" + "<br/>" + "<p>" + "Outlined below is a summary of your submitted enquiry:" + "</p>" + "<p>" + "\"" + tbxQuery.Text + "\"" + "</p>" + "<br/>" + "<p>" + "Kind Regards," + "</p>" + "<p>" + "The JerseySure Team" + "</p>"; try { BLEmail.SendEmail(tbxEmail.Text, "Contact Form Query - JerseySure", mailbody); } catch (Exception ex) { // Display error page for unable to send email Response.Redirect("~/UL/ErrorPage/1"); } Response.Redirect("~/UL/SuccessPage/2"); } }
private void ErrorPopup_FormClosing(object sender, FormClosingEventArgs e) { //!sendCustomEmail = If the user has not given a description of the exception and sent it. //allowEmail determines if we are allowed to send an e-mail(it's only allowed once every 30 seconds to prevent spam) if (!sentCustomEmail && allowEmail) { try { string mess = "Oops! An error has occured. Here's the details:\r\n\r\n" + ex.ToString(); if (ex is ReminderException) { ReminderException theException = (ReminderException)ex; theException.Reminder.Note = "Removed for privacy reasons"; theException.Reminder.Name = "Removed for privacy reasons"; mess += "\r\n\r\nThis exception is an ReminderException! Let's see if we can figure out what's wrong with it....\r\n"; mess += "ID: " + theException.Reminder.Id + "\r\n"; mess += "Deleted: " + theException.Reminder.Deleted + "\r\n"; mess += "Date: " + theException.Reminder.Date + "\r\n"; mess += "RepeatType: " + theException.Reminder.RepeatType + "\r\n"; mess += "Enabled: " + theException.Reminder.Enabled + "\r\n"; mess += "DayOfMonth: " + theException.Reminder.DayOfMonth + "\r\n"; mess += "EveryXCustom: " + theException.Reminder.EveryXCustom + "\r\n"; mess += "RepeatDays: " + theException.Reminder.RepeatDays + "\r\n"; mess += "SoundFilePath: " + theException.Reminder.SoundFilePath + "\r\n"; mess += "PostponeDate: " + theException.Reminder.PostponeDate + "\r\n"; mess += "Hide: " + theException.Reminder.Hide + "\r\n\r\n"; mess += "=== Displaying date culture info, so you might be able to re-create the reminder ===\r\n"; mess += "Current culture DisplayName: " + CultureInfo.CurrentCulture.DisplayName + "\r\n"; mess += "Current culture ShortTimePattern: " + CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern + "\r\n"; mess += "Current culture ShortDatePattern: " + CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern + "\r\n"; mess += "Current culture ToString(): " + CultureInfo.CurrentCulture.ToString() + "\r\n"; } Thread sendMailThread = new Thread(() => BLEmail.SendEmail("Error Report: " + ex.GetType().ToString(), mess)); sendMailThread.Start(); } catch { } } }
private void btnSubmit_Click(object sender, EventArgs e) { try { string textBoxText = tbNote.Text; //Cant access tbNote in a thread. save the text in a variable instead string customMess = "[CUSTOM USER INPUT]\r\n" + textBoxText + "\r\n\r\n---------------Default below--------------------\r\nOops! An error has occured. Here's the details:\r\n\r\n" + ex.ToString(); if (ex is ReminderException) { ReminderException theException = (ReminderException)ex; if (theException.Reminder != null) { theException.Reminder.Note = "Removed for privacy reasons"; theException.Reminder.Name = "Removed for privacy reasons"; customMess += "\r\n\r\nThis exception is an ReminderException! Let's see if we can figure out what's wrong with it....\r\n"; customMess += "ID: " + theException.Reminder.Id + "\r\n"; customMess += "Deleted: " + theException.Reminder.Deleted + "\r\n"; customMess += "Date: " + theException.Reminder.Date + "\r\n"; customMess += "RepeatType: " + theException.Reminder.RepeatType + "\r\n"; customMess += "Enabled: " + theException.Reminder.Enabled + "\r\n"; customMess += "DayOfMonth: " + theException.Reminder.DayOfMonth + "\r\n"; customMess += "EveryXCustom: " + theException.Reminder.EveryXCustom + "\r\n"; customMess += "RepeatDays: " + theException.Reminder.RepeatDays + "\r\n"; customMess += "SoundFilePath: " + theException.Reminder.SoundFilePath + "\r\n"; customMess += "PostponeDate: " + theException.Reminder.PostponeDate + "\r\n"; customMess += "Hide: " + theException.Reminder.Hide + "\r\n"; } } Thread sendMailThread = new Thread(() => BLEmail.SendEmail("[CUSTOM] | Error Report: " + ex.GetType().ToString(), customMess)); sendMailThread.Start(); MessageFormManager.MakeMessagePopup("Feedback sent.\r\nThank you for taking the time!", 5); this.Dispose(); } catch { } //Set this boolean to true so that when this popup closes, we won't try to send another e-mail sentCustomEmail = true; }