protected void btnShowReport_Click(object sender, EventArgs e) { EmailContentDAL newContentDal = new EmailContentDAL(); UserSelection newSelection = new UserSelection(); EmailContent emailContent = newContentDal.GetEmailContentByID(BatchID, out newSelection); if (newSelection != null) { PopulateSelectionCriterion(newSelection); } if (emailContent != null) { PopulateEmailContent(emailContent); } EmailDeliveryDAL newDal = new EmailDeliveryDAL(); IList <EmailDelivery> emails = newDal.GetSendEmail(BatchID); gvEmailSend.PageIndex = 0; gvEmailSend.DataSource = emails; gvEmailSend.DataBind(); if (emails.Count > 10) { lblResult.Text = string.Format("Showing result(s) 1-10 of {0}", emails.Count.ToString()); } else if (emails.Count > 0) { lblResult.Text = string.Format("Showing result(s) 1-{0} of {0}", emails.Count.ToString()); } else { lblResult.Text = string.Empty; } }
protected void Page_Load(object sender, EventArgs e) { lblCancelAll.Text = string.Empty; if (!IsPostBack) { EmailContentDAL newContentDal = new EmailContentDAL(); IList <UserSelection> newSelection = new List <UserSelection>(); IList <EmailContent> emailContents = newContentDal.GetEmailContents(out newSelection); int limit = 0; foreach (EmailContent content in emailContents) { ListItem item = new ListItem(); item.Text = content.EmailContentID.ToString(); item.Value = content.EmailContentID.ToString(); ddlBatchID.Items.Add(item); limit++; //if (limit > 49) break; } ddlBatchID.SelectedIndex = 0; if (newSelection != null && newSelection.Count > 0) { PopulateSelectionCriterion(newSelection[0]); } if (emailContents != null && emailContents.Count > 0) { PopulateEmailContent(emailContents[0]); } EmailDeliveryDAL newDal = new EmailDeliveryDAL(); IList <EmailDelivery> emails = newDal.GetSendEmail(BatchID); gvEmailSend.DataSource = emails; gvEmailSend.DataBind(); if (emails.Count > 10) { lblResult.Text = string.Format("Showing result(s) 1-10 of {0}", emails.Count.ToString()); } else if (emails.Count > 0) { lblResult.Text = string.Format("Showing result(s) 1-{0} of {0}", emails.Count.ToString()); } else { lblResult.Text = string.Empty; } } }
protected void SendMailtoList(IList <Entity.User> users) { EmailContent newContent = populateEmailContent(); UserSelection newSelection = populateSelectionParameters(); EmailContentDAL newContentDal = new EmailContentDAL(); int emailContentID = newContentDal.SaveEmailContent(newContent, newSelection); int count = 0; StringBuilder sb = new StringBuilder(); foreach (Entity.User _user in users) { string status = SendMail(_user, emailContentID); if (string.IsNullOrEmpty(status)) { count++; } } sb.AppendFormat("Email(s) are Scheduled Successfully for {0} user(s). Click <a href='EmailSendReport.aspx'>here</a> to view the schedule status.", count); lblMsg.Text = sb.ToString(); }