protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { int emailID = Convert.ToInt32(Request.QueryString["emailID"]); // create object qCom_EmailTool email = new qCom_EmailTool(emailID); qPtl_User user = new qPtl_User(Convert.ToInt32(Context.Items["UserID"])); txtEmail.Text = user.Email; lblSubject.Text = email.emailSubject; // get headers and footers string query = "SELECT TOP(1) * FROM qCom_EmailPreferences WHERE Available = 'Yes'"; qDbs_SQLcode sql = new qDbs_SQLcode(); SqlDataReader eReader = sql.GetDataReader(query); eReader.Read(); string header = Convert.ToString(eReader["Header"]); string footer = Convert.ToString(eReader["Footer"]); string unsubscribe = Convert.ToString(eReader["Unsubscribe"]); eReader.Close(); // if email type is bulk, then add footer string completeMessage = header + email.emailDraft + footer; if (email.emailType == "bulk") { completeMessage += unsubscribe; } lblBody.Text = completeMessage; } }
public void Insert() { NotificationID = Convert.ToInt32(container.Insert()); //if email notification enabled, send an email string send_notification_email = System.Configuration.ConfigurationManager.AppSettings["Email_SendNotificationEmail"]; if (!String.IsNullOrEmpty(send_notification_email)) { if (send_notification_email == "true") { qPtl_Notification notification = new qPtl_Notification(NotificationID); qPtl_User owner = new qPtl_User(notification.OwnerID); qPtl_User actor = new qPtl_User(notification.ActorID); int notification_email_id = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["Email_NotificationEmailID"]); if (!String.IsNullOrEmpty(Convert.ToString(notification_email_id))) { if (notification_email_id > 0) { try { qCom_EmailTool email = new qCom_EmailTool(notification_email_id); email.SendDatabaseMail(owner.Email, notification_email_id, owner.UserID, notification.Text, actor.UserName, "", "", "", false); } catch { // do nothing } } } } } }
protected void sendNow() { int emailID = Convert.ToInt32(Request.QueryString["emailID"]); // create object qCom_EmailTool email = new qCom_EmailTool(emailID); qPtl_User user = new qPtl_User(Convert.ToInt32(Context.Items["UserID"])); email.SendDatabaseMail(txtEmail.Text, Convert.ToInt32(Request.QueryString["emailID"]), user.UserID, user.UserName, txtValue1.Text, txtValue2.Text, txtValue3.Text, txtValue4.Text, false); lblMessage.Text = "* Email Successfully Sent"; lblMessage.Visible = true; }
protected void btnRequestPasswordReset_Click(object sender, EventArgs e) { var user = qPtl_User.GetUserByEmail(txtOrigEmail.Text); if (user != null) { if (user.UserID > 0) { if (user.SetPasswordResetCode(user.UserID)) { // create object int emailID = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["Email_ForgotPasswordID"]); qCom_EmailTool email = new qCom_EmailTool(emailID); qPtl_User updated_user = new qPtl_User(user.UserID); int sent_email_log_id = email.SendDatabaseMail(updated_user.Email, emailID, updated_user.UserID, updated_user.UserName, updated_user.PasswordResetCode, Request.Url.Authority + HttpRuntime.AppDomainAppVirtualPath.TrimEnd('/'), string.Empty, string.Empty, false); if (sent_email_log_id > 0) { lblMsgRequest.Text = "<br>Please check your email for further instructions"; txtOrigEmail.Visible = false; btnRequestPasswordReset.Visible = false; hplCancelRequest.Visible = false; } else { lblMsgRequest.Text = "<br><br>An error occured sending an email, please contact support"; } } else { lblMsgRequest.Text = "<br><br>An error occured setting the reset code, please contact support"; } } } else { lblMsgRequest.Text = "<br><br>Email address not found"; } }
protected void SendTaskEmail(int task_type_id, int created_by, int reference_id, string description) { string request_task_emails = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["TaskEmailList"]); qCom_EmailPreference preferences = new qCom_EmailPreference(); string system_from = preferences.FromName; string system_email_address = preferences.FromEmailAddress; int curr_email_id = 0; qPtl_User curr_user = new qPtl_User(created_by); if (!String.IsNullOrEmpty(request_task_emails)) { switch (task_type_id) { case 1: // review blog curr_email_id = Convert.ToInt32(Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["report_blog_EmailID"])); break; case 2: // approve image curr_email_id = Convert.ToInt32(Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["report_newpic_EmailID"])); break; case 3: // approve video curr_email_id = Convert.ToInt32(Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["report_video_EmailID"])); break; case 4: // review site report curr_email_id = Convert.ToInt32(Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["report_issue_EmailID"])); break; case 5: // review reported message curr_email_id = Convert.ToInt32(Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["report_message_EmailID"])); break; case 6: // review banned word curr_email_id = Convert.ToInt32(Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["report_banned_word_EmailID"])); break; } qCom_EmailItem email = new qCom_EmailItem(curr_email_id); ArrayList addresses = new ArrayList(); q_Helper helper = new q_Helper(); addresses = helper.optionsToArrayList(request_task_emails); qCom_EmailTool email_send = new qCom_EmailTool(); int sent_email_log_id = 0; foreach (string address in addresses) { try { sent_email_log_id = email_send.SendDatabaseMail(address, curr_email_id, created_by, curr_user.UserName, Convert.ToString(reference_id), description, "", "", false); } catch { // email failure } } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { // get all send events string sqlCode = string.Empty; sqlCode = "SELECT * FROM qCom_SendEvents_View WHERE (Available = 'Yes' AND Running = 'Yes' AND Recurring = 'Yes' AND GetDate() > StartDate) OR (Available = 'Yes' AND Running = 'Yes' AND Recurring = 'No' AND (GetDate() Between StartDate AND StartDate+1)) ORDER BY Priority ASC"; qDbs_SQLcode sql = new qDbs_SQLcode(); SqlDataReader eReader = sql.GetDataReader(sqlCode); if (eReader.HasRows) { while (eReader.Read()) { // see if there are custom email preferences if this send event is associated with a campaign int campaign_id = 0; string custom_email = string.Empty; string custom_email_from = string.Empty; bool get_custom_did = false; if (!String.IsNullOrEmpty(Convert.ToString(eReader["CampaignID"]))) { campaign_id = Convert.ToInt32(eReader["CampaignID"]); } if (campaign_id > 0) { var pref = qCom_CampaignPreference.GetCampaignPreferences(campaign_id); if (pref != null) { if (pref.CampaignPreferenceID > 0) { if (!String.IsNullOrEmpty(pref.CampaignEmail)) { custom_email = pref.CampaignEmail; } if (!String.IsNullOrEmpty(pref.CampaignEmailFrom)) { custom_email_from = pref.CampaignEmailFrom; } // see if we need to get / integrated a custom DID if (pref.IncludeCustomDID == true) { get_custom_did = true; } } } } // get email preferences string sqlCode2 = "SELECT TOP(1) * FROM qCom_EmailPreferences WHERE Available = 'Yes'"; SqlDataReader pReader = sql.GetDataReader(sqlCode2); pReader.Read(); string header = Convert.ToString(pReader["Header"]); string footer = Convert.ToString(pReader["Footer"]); string unsubscribe = Convert.ToString(pReader["Unsubscribe"]); string fromEmailAddress = string.Empty; string fromName = string.Empty; if (!String.IsNullOrEmpty(custom_email)) { fromEmailAddress = custom_email; } else { fromEmailAddress = Convert.ToString(pReader["FromEmailAddress"]); } if (!String.IsNullOrEmpty(custom_email_from)) { fromName = custom_email_from; } else { fromName = Convert.ToString(pReader["fromName"]); } pReader.Close(); //try //{ lblMessage.Text += "<br>Sending..."; // create object int emailID = Convert.ToInt32(eReader["emailID"]); string contactQuery = "SELECT " + Convert.ToString(eReader["sqlSELECT"]) + " FROM " + Convert.ToString(eReader["sqlFROM"]) + " WHERE " + Convert.ToString(eReader["sqlWHERE"]); bool is_contact_list = false; if (Convert.ToString(eReader["sqlFROM"]).Contains("qCom_Contacts")) { is_contact_list = true; } qCom_EmailTool email = new qCom_EmailTool(emailID); // get addresses string[][] contacts = email.GetSendEventContacts(contactQuery, get_custom_did, campaign_id, Convert.ToInt32(Context.Items["ScopeID"]), is_contact_list); string messageBody = string.Empty; string includeHeader = Convert.ToString(eReader["IncludeHeader"]); string includeFooter = Convert.ToString(eReader["IncludeFooter"]); string includeUnsubscribe = Convert.ToString(eReader["IncludeUnsubscribe"]); if (includeHeader == "Yes") { messageBody += header; } messageBody += email.emailDraft; if (includeFooter == "Yes") { messageBody += footer; } if (includeUnsubscribe == "Yes") { messageBody += unsubscribe; } //(string[][] addresses, string strFrom, string strFromEmail, string requestURL, string strSubject, string rawEmailContent, string userID, string value1, string value2, bool sendCopyToAdmins, bool noDuplicatesToday, bool noDontSend, int emailID) ArrayList[] output = email.SendMail(contacts, fromName, fromEmailAddress, "bulkemail", email.emailSubject, messageBody, "", "", "", "", "", false, true, true, emailID, get_custom_did, campaign_id); lblMessage.Text += "finished sending email: " + email.emailSubject + "; send event id = " + Convert.ToString(eReader["SendEventID"]) + "; number of recipients=" + contacts.Length; //} //catch //{ // lblMessage.Text += "A problem has occurred<br>"; //} } eReader.Close(); } else { lblMessage.Text += "There are no scheduled send events.<br>"; } } else { lblMessage.Text += "Problem with key or page incorrectly loaded.<br>"; } }