代码:-
List<Task> tasks = new List<Task>();
foreach (var item in arr)//arr contains 1000+ mailids
{
tasks.Add(Task.Factory.StartNew(() =>
{
using (MailMessage msg = new MailMessage())
{
msg=getmsg();//p-shadow code no erorr here
SmtpClient smtp = new SmtpClient();
smtp.Host = smtpServer;
smtp.Port = smtpPort;
smtp.EnableSsl = isSmtpSsl != 0 ? true : false;
smtp.Credentials = new NetworkCredential(smtpUName,smtpPass);
smtp.Timeout = int.MaxValue;
smtp.Send(msg);//---throws error....
//sql code to insert db that mail is send
}
}, TaskCreationOptions.LongRunning));
}
Task.WaitAll(tasks.ToArray<Task>());
错误-“发送邮件失败。”
内部错误-“无法从传输连接读取数据:net_io_connectionclosed。”