private void BatchSendEmail_Click(object sender, EventArgs e) { if (base.CheckCookie()) { this.groupidlist = this.Usergroups.GetSelectString(","); if (String.IsNullOrEmpty(this.groupidlist) && String.IsNullOrEmpty(this.usernamelist.Text.Trim())) { base.RegisterStartupScript("", "<script>alert('您需要输入接收邮件用户名称或选取相关的用户组,因此邮件无法发送');</script>"); return; } int num = 5; if (!this.usernamelist.Text.IsNullOrEmpty()) { //DataTable list = Users.GetEmailListByUserNameList(this.usernamelist.Text); var list = XUser.FindAllByName(usernamelist.Text); if (list.Count <= 0) { base.RegisterStartupScript("", "<script>alert('您输入的接收邮件用户名未能查找到相关用户,因此邮件无法发送');</script>"); return; } //Thread[] array = new Thread[list.Count]; int num2 = 0; foreach (var item in list) { //EmailMultiThread em = new EmailMultiThread(dataRow["UserName"].ToString(), dataRow["Email"].ToString(), this.subject.Text, this.body.Text); //array[num2] = new Thread(new ThreadStart(em.Send)); //array[num2].Start(); Emails.SendAsync(item.Name, item.Email, this.subject.Text, this.body.Text); if (num2 >= num) { Thread.Sleep(5000); num2 = 0; } num2++; } } if (String.IsNullOrEmpty(this.groupidlist)) { base.LoadRegisterStartupScript("PAGE", "window.location.href='global_usergroupsendemail.aspx';"); return; } base.ClientScript.RegisterStartupScript(base.GetType(), "Page", "<script>submit_Click();</script>"); } }