private void Sends() { try { string strForm = iniCls.IniReadValue("SMTP", "txtAddr"); //发件人地址 string senderDisplayName = iniCls.IniReadValue("SMTP", "DisplayName"); //发件人名称 string userPswd = iniCls.IniReadValue("SMTP", "txtPwd"); //用户密码 string strHost = iniCls.IniReadValue("SMTP", "txtSmtp"); //服务器地址 int port = int.Parse(iniCls.IniReadValue("SMTP", "txtPort")); //服务器端口 int sendCount = int.Parse(iniCls.IniReadValue("SMTP", "sendCount")); //每次发送数量 strFilePath = txtAtt.Text.Trim(); //附件路径 string strSubject = txtTitle.Text.Trim(); //邮件标题 //if (CHKSave.Checked) //{ // InsertEmailContent(strSubject, strBody);//保存邮件内容 //} while (lstMail.Items.Count > 0) { arrStrTO = lstMail.GetItemText(lstMail.Items[0]); Megs = "正发送:" + arrStrTO + ", 已成功发送" + SendSucc + "封邮件,失败" + SendFail + "封邮件"; MethodInvoker In = new MethodInvoker(lblValue); this.BeginInvoke(In); if (sdms.SendEmailTo(arrStrTO.Trim(), strForm.Trim(), senderDisplayName, userPswd, strSubject, strBody, strHost, port, strFilePath) == true) { MethodInvoker Ins = new MethodInvoker(DeleMailLst); this.BeginInvoke(Ins); SendSucc++; } else { MethodInvoker Ins = new MethodInvoker(DeleMailLst); this.BeginInvoke(Ins); SendFail++; } if (SendSucc + SendFail > sendCount) { SendSucc = 0; SendFail = 0; break; } } MethodInvoker Inss = new MethodInvoker(BtnEnabled); this.BeginInvoke(Inss); //MethodInvoker InCombox = new MethodInvoker(changeComboxSelectIndex); //this.BeginInvoke(InCombox); } catch { Didi(); } }