protected void ddlMailListGroups_SelectedIndexChanged(object sender, EventArgs e) { Languages langID = Languages.Unknowen; if (trLanguages.Visible) { langID = (Languages)Convert.ToInt32(ddlLanguages.SelectedValue); } Chkusers.Items.Clear(); if (ddlMailListGroups.SelectedValue != "" && ddlMailListGroups.SelectedValue != "-1") { int groupID = Convert.ToInt32(ddlMailListGroups.SelectedValue); List <string> users = MailListUsersFactory.GetAllEmailsOnly(ModuleTypeID, langID, groupID, true); foreach (string email in users) { Chkusers.Items.Add(email); } trselectedusers.Visible = true; } else { trselectedusers.Visible = false; } }
//-------------------------------------------------------- protected void btnSend_Click(object sender, EventArgs e) { if (cblMailListGroups.SelectedIndex < 0) { General.MakeAlertError(lblResult, Resources.MailListAdmin.Result_ChoesOneGroupAtLeast); return; } //------------------------------------------------------------- Languages langID = Languages.Unknowen; if (trLanguages.Visible) { langID = (Languages)Convert.ToInt32(ddlLanguages.SelectedValue); } //------------------------------------------------------------- #region Attachments if (SiteSettings.MailList_HasAttachments) { //----------------------------------------------------------------- attachmentsPathes = new List <string>(); MailListEmailsFactory.AddAttatchPath(attachmentsPathes, fuAttach1); MailListEmailsFactory.AddAttatchPath(attachmentsPathes, fuAttach2); MailListEmailsFactory.AddAttatchPath(attachmentsPathes, fuAttach3); //----------------------------------------------------------------- } #endregion ////////////////////////////////////////////////////////////////////////////////////// int groupID; List <string> usersList; foreach (ListItem item in cblMailListGroups.Items) { if (item.Selected) { groupID = Convert.ToInt32(item.Value); usersList = MailListUsersFactory.GetAllEmailsOnly(ModuleTypeID, langID, groupID, true); foreach (string userEMail in usersList) { if (mail == null) { BuildEmail(); } mail.To.Add(userEMail); MailListEmailsFactory.Send(mail); mail.Dispose(); mail = null; } } } //SaveArchive //if (usersList.Count > 0) SaveArchive(); //------------------------------------------- /////////////////////////////////////////////////////////////////////////////////// General.MakeAlertSucess(lblResult, Resources.MailListAdmin.Result_SendingDone); }
//-------------------------------------------------------- protected void btnSend_Click(object sender, EventArgs e) { List <string> usersList = null; if (FormMailTo != FormMailToTypes.One) { //------------------------------------------------------------- int groupID = -1;// UnSpecified if (trGroups.Visible) { groupID = Convert.ToInt32(ddlMailListGroups.SelectedValue); } //------------------------------------------------------------- Languages langID = Languages.Unknowen; if (trLanguages.Visible) { langID = (Languages)Convert.ToInt32(ddlLanguages.SelectedValue); } //------------------------------------------------------------- usersList = MailListUsersFactory.GetAllEmailsOnly(ModuleTypeID, langID, groupID, true); } //try //{ #region Attachments if (SiteSettings.MailList_HasAttachments) { //----------------------------------------------------------------- attachmentsPathes = new List <string>(); MailListEmailsFactory.AddAttatchPath(attachmentsPathes, fuAttach1); MailListEmailsFactory.AddAttatchPath(attachmentsPathes, fuAttach2); MailListEmailsFactory.AddAttatchPath(attachmentsPathes, fuAttach3); //----------------------------------------------------------------- } #endregion ////////////////////////////////////////////////////////////////////////////////////// int maxBccCount = SiteSettings.MailList_MaxBccCount; if (FormMailTo == FormMailToTypes.One) { //mail = new MailListEmailsEntity(); BuildEmail(0, txtEmail.Text); mail.To.Add(txtEmail.Text); MailListEmailsFactory.Send(mail); //SaveArchive SaveArchive(); } else { foreach (string userEMail in usersList) { if (mail == null) { BuildEmail(0, userEMail); } mail.To.Add(userEMail); MailListEmailsFactory.Send(mail); mail.Dispose(); mail = null; } //SaveArchive if (usersList.Count > 0) { SaveArchive(); } /* * int x = 0; * foreach (MailListUsersEntity user in usersList) * { ++x; * if (mail == null) BuildEmail(); * mail.Bcc.Add(user.Email); * if (x >= maxBccCount) * { * //BuildEmail(mail, attachmentsPathes); * MailListEmailsFactory.Send(mail); * //Clear Bcc * * mail.Bcc.Clear(); * mail.Dispose(); * mail = null; * x = 0; * } * } * if (x > 0)//Send to the last emails * { * MailListEmailsFactory.Send(mail); * }*/ //------------------------------------------- } /////////////////////////////////////////////////////////////////////////////////// lblResult.CssClass = "operation_done"; lblResult.Text = Resources.MailListAdmin.Result_SendingDone; }