/// <summary> /// Handles OnUpdate event /// </summary> /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param> protected override void OnUpdate(EventArgs e) { string email; Label lblEMail; CheckBox chkSelect; foreach (RepeaterItem SelectItem in repListItem.Items) { lblEMail = (Label)SelectItem.FindControl("lblEMail"); email = lblEMail.Text; chkSelect = (CheckBox)SelectItem.FindControl("chkSelect"); if (chkSelect.Checked) { //BlacklistDB.AddToBlackList(this.portalSettings.PortalID, email, "Blacklisted by " + Context.User.Identity.Name); // Added EsperantusKeys for Localization // Mario Endara [email protected] june-1-2004 BlacklistDB.AddToBlackList(this.PortalSettings.PortalID, email, General.GetString("NEWSLETTER_BLACKLISTED") + PortalSettings.CurrentUser.Identity.Email); } else { BlacklistDB.DeleteFromBlackList(this.PortalSettings.PortalID, email); } } // Redirect back to the portal home page RedirectBackToReferringPage(); }
/// <summary> /// The SubmitBtn_Click server event handler on this page is used /// to handle the scenario where a user clicks the "send" /// button after entering a response to a message post. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param> private void submitButton_Click(object sender, EventArgs e) { string message; int cnt = 0; EditPanel.Visible = false; PrewiewPanel.Visible = true; UsersPanel.Visible = false; SmtpMail.SmtpServer = Config.SmtpServer; message = General.GetString("NEWSLETTER_SENDTO", "<b>Message:</b> sent to:<br>"); try { NewsletterDB newsletter = new NewsletterDB(); if (!bool.Parse(Settings["TestMode"].ToString())) { // Get Newsletter Users from DB SqlDataReader dReader = newsletter.GetUsersNewsletter(portalSettings.PortalID, Int32.Parse(Settings["NEWSLETTER_USERBLOCK"].ToString()), Int32.Parse(Settings["NEWSLETTER_DONOTRESENDWITHIN"].ToString())); try { while (dReader.Read()) { cnt++; message += dReader["Email"].ToString() + ", "; try { //Send the email newsletter.SendMessage(txtEMail.Text, dReader["Email"].ToString(), dReader["Name"].ToString(), dReader["Password"].ToString(), Settings["NEWSLETTER_LOGINHOMEPAGE"].ToString(), txtSubject.Text, txtBody.Text, true, HtmlMode.Checked, InsertBreakLines.Checked); //Update db newsletter.SendNewsletterTo(portalSettings.PortalID, dReader["Email"].ToString()); } catch (Exception ex) { InvalidRecipients += dReader["Email"].ToString() + "<br>"; BlacklistDB.AddToBlackList(portalSettings.PortalID, dReader["Email"].ToString(), ex.Message); } } } finally { dReader.Close(); //by Manu, fixed bug 807858 } lblMessage.Text = General.GetString("NEWSLETTER_SENDINGTO", "Message has been sent to {1} registered users."). Replace("{1}", cnt.ToString()); } else { newsletter.SendMessage(txtEMail.Text, txtEMail.Text, txtName.Text, "******", Settings["NEWSLETTER_LOGINHOMEPAGE"].ToString(), txtSubject.Text, txtBody.Text, true, HtmlMode.Checked, InsertBreakLines.Checked); lblMessage.Text = General.GetString("NEWSLETTER_TESTSENDTO", "Test message sent to: ") + txtName.Text + " [" + txtEMail.Text + "]"; } } catch (Exception ex) { lblMessage.Text = General.GetString("NEWSLETTER_ERROR", "An error occurred: ") + ex.Message; } CreatedDate.Text = General.GetString("NEWSLETTER_SENDDATE", "Message sent: ") + DateTime.Now.ToLongDateString() + "<br>"; if (InvalidRecipients.Length > 0) { CreatedDate.Text += General.GetString("NEWSLETTER_INVALID_RECIPIENTS", "Invalid recipients:<br>") + InvalidRecipients; } //Hides commands submitButton.Visible = false; cancelButton2.Visible = false; }
/// <summary> /// The SubmitBtn_Click server event handler on this page is used /// to handle the scenario where a user clicks the "send" /// button after entering a response to a message post. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param> private void submitButton_Click(object sender, EventArgs e) { string message; int cnt = 0; EditPanel.Visible = false; PrewiewPanel.Visible = true; UsersPanel.Visible = false; message = General.GetString("NEWSLETTER_SENDTO", "<b>Message:</b> sent to:<br>"); try { NewsletterDB newsletter = new NewsletterDB(); if (!bool.Parse(Settings["TestMode"].ToString())) { // Get Newsletter Users from DB var users = newsletter.GetUsersNewsletter(this.PortalSettings.PortalID); foreach (dynamic user in users) { cnt++; message += user.Email + ", "; try { //Send the email newsletter.SendMessage(txtEMail.Text, user.Email, user.Name, txtSubject.Text, txtBody.Text, true, HtmlMode.Checked, InsertBreakLines.Checked); // Here the systems used to notify the DB that an email was sent to the user. // Since we implemented the MembershipProvider for Appleseed, we doesn't have a place to store this info, // thus, now the fact that an email was sent won't be persisted in the DB. However this should change in future releases. } catch (Exception ex) { InvalidRecipients += user.Email + "<br/>"; BlacklistDB.AddToBlackList(this.PortalSettings.PortalID, user.Email, ex.Message); } } lblMessage.Text = General.GetString("NEWSLETTER_SENDINGTO", "Message has been sent to {1} registered users."). Replace("{1}", cnt.ToString()); } else { newsletter.SendMessage(txtEMail.Text, txtEMail.Text, txtName.Text, txtSubject.Text, txtBody.Text, true, HtmlMode.Checked, InsertBreakLines.Checked); lblMessage.Text = General.GetString("NEWSLETTER_TESTSENDTO", "Test message sent to: ") + txtName.Text + " [" + txtEMail.Text + "]"; } } catch (Exception ex) { lblMessage.Text = General.GetString("NEWSLETTER_ERROR", "An error occurred: ") + ex.Message; } CreatedDate.Text = General.GetString("NEWSLETTER_SENDDATE", "Message sent: ") + DateTime.Now.ToLongDateString() + "<br>"; if (InvalidRecipients.Length > 0) { CreatedDate.Text += General.GetString("NEWSLETTER_INVALID_RECIPIENTS", "Invalid recipients:<br>") + InvalidRecipients; } //Hides commands submitButton.Visible = false; cancelButton2.Visible = false; }