public void SendEmailTo(string whatname, string to, string subject, string body)
{
try
{
MailMessage msg = new MailMessage(new MailAddress(this.form, whatname), new MailAddress(to));
msg.Subject = subject;
msg.Body = body;
msg.IsBodyHtml = true;
SmtpClient client = new SmtpClient(this.stmp, 25);
client.Credentials = new NetworkCredential(this.form, this.pwd);
client.Timeout = 8000;
client.ServicePoint.MaxIdleTime = 10000;
client.Send(msg);
msg.Dispose();
SetEmailTrue = true;
}
catch( Exception ex)
{
SetEmailTrue = false;
this.emailform.NoticerichTextBox.Invoke(this.emailform.AppNoticeByThread, "\t" + EmailToosMainform.SelCount.ToString() + "、" + this.email.ToString() + "发送至" + to.ToString() + "邮箱 出现异常" + ex.Message.ToString() + ",后续再调用!\n", Color.Red, 10, true);
}
}SmtpClient 就想隔一段时间释放一下资源,发现也没有close 也没有dispose 听说.net 4.0版本才有,难道没有办法了吗? net 3.5 大量邮件群发以后,没有办法释放stmpclient的资源了吗?
群发大概100多封以后出现[email protected]发送至[email protected]邮箱 出现异常服务不可用,正在关闭传输信道
服务器响应为: 4.7.0 mail.umail174.cn4e.com Error: too many connections from 119.139.122.162,后续再调用!
关闭软件,2分钟以后又可以发100多封了。
{
try
{
MailMessage msg = new MailMessage(new MailAddress(this.form, whatname), new MailAddress(to));
msg.Subject = subject;
msg.Body = body;
msg.IsBodyHtml = true;
SmtpClient client = new SmtpClient(this.stmp, 25);
client.Credentials = new NetworkCredential(this.form, this.pwd);
client.Timeout = 8000;
client.ServicePoint.MaxIdleTime = 10000;
client.Send(msg);
msg.Dispose();
SetEmailTrue = true;
}
catch( Exception ex)
{
SetEmailTrue = false;
this.emailform.NoticerichTextBox.Invoke(this.emailform.AppNoticeByThread, "\t" + EmailToosMainform.SelCount.ToString() + "、" + this.email.ToString() + "发送至" + to.ToString() + "邮箱 出现异常" + ex.Message.ToString() + ",后续再调用!\n", Color.Red, 10, true);
}
}SmtpClient 就想隔一段时间释放一下资源,发现也没有close 也没有dispose 听说.net 4.0版本才有,难道没有办法了吗? net 3.5 大量邮件群发以后,没有办法释放stmpclient的资源了吗?
群发大概100多封以后出现[email protected]发送至[email protected]邮箱 出现异常服务不可用,正在关闭传输信道
服务器响应为: 4.7.0 mail.umail174.cn4e.com Error: too many connections from 119.139.122.162,后续再调用!
关闭软件,2分钟以后又可以发100多封了。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货