该进程无法访问该文件,因为它正被另一个进程使用(文件数量后发生错误)
The process cannot access the file because it is being used by another process (Error occur after numbers of files)
我发送了一些带有附件的电子邮件。每 56 封邮件都会出错。错误的详细信息是:
System.Net.Mail.SmtpException: Failure sending mail. --->
System.IO.IOException: Unable to write data to the transport
connection: An established connection was aborted by the software in
your host machine. ---> System.Net.Sockets.SocketException: An
established connection was aborted by the software in your host
machine at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32
offset, Int32 size, SocketFlags socketFlags) at
System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset,
Int32 size) --- End of inner exception stack trace --- at
System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset,
Int32 size) at System.Net.DelegatedStream.Write(Byte[] buffer,
Int32 offset, Int32 count) at
System.Net.DelegatedStream.Write(Byte[] buffer, Int32 offset, Int32
count) at System.Net.Mime.SevenBitStream.Write(Byte[] buffer, Int32
offset, Int32 count) at System.Net.DelegatedStream.Write(Byte[]
buffer, Int32 offset, Int32 count) at
System.Net.DelegatedStream.Write(Byte[] buffer, Int32 offset, Int32
count) at System.Net.Mime.SevenBitStream.Write(Byte[] buffer, Int32
offset, Int32 count) at System.Net.DelegatedStream.Write(Byte[]
buffer, Int32 offset, Int32 count) at
System.Net.DelegatedStream.Write(Byte[] buffer, Int32 offset, Int32
count) at System.Net.Base64Stream.FlushInternal() at
System.Net.Base64Stream.Write(Byte[] buffer, Int32 offset, Int32
count) at System.Net.Mime.MimePart.Send(BaseWriter writer) at
System.Net.Mime.MimeMultiPart.Send(BaseWriter writer) at
System.Net.Mail.Message.Send(BaseWriter writer, Boolean sendEnvelope)
at System.Net.Mail.MailMessage.Send(BaseWriter writer, Boolean
sendEnvelope) at System.Net.Mail.SmtpClient.Send(MailMessage
message) --- End of inner exception stack trace --- at
System.Net.Mail.SmtpClient.Send(MailMessage message)
我在 google 中找到了一些类似的答案,但它不起作用。有人可以帮忙吗?我正在使用无法使用 SmtpClient.Dispose()
的 .NET 3.5
这是类似的问题:
我终于找到了问题的答案。它非常适合为以前的 .net 处理 smtpclient。
Does system.net.mail.smptclient disconnect from the server?
这是代码
var smtp = new SmtpClient();
smtp.ServicePoint.MaxIdleTime = 1;
smtp.ServicePoint.ConnectionLimit = 1;
smtp.Send(message);
我发送了一些带有附件的电子邮件。每 56 封邮件都会出错。错误的详细信息是:
System.Net.Mail.SmtpException: Failure sending mail. ---> System.IO.IOException: Unable to write data to the transport connection: An established connection was aborted by the software in your host machine. ---> System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size) --- End of inner exception stack trace --- at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size) at System.Net.DelegatedStream.Write(Byte[] buffer, Int32 offset, Int32 count) at System.Net.DelegatedStream.Write(Byte[] buffer, Int32 offset, Int32 count) at System.Net.Mime.SevenBitStream.Write(Byte[] buffer, Int32 offset, Int32 count) at System.Net.DelegatedStream.Write(Byte[] buffer, Int32 offset, Int32 count) at System.Net.DelegatedStream.Write(Byte[] buffer, Int32 offset, Int32 count) at System.Net.Mime.SevenBitStream.Write(Byte[] buffer, Int32 offset, Int32 count) at System.Net.DelegatedStream.Write(Byte[] buffer, Int32 offset, Int32 count) at System.Net.DelegatedStream.Write(Byte[] buffer, Int32 offset, Int32 count) at System.Net.Base64Stream.FlushInternal() at System.Net.Base64Stream.Write(Byte[] buffer, Int32 offset, Int32 count) at System.Net.Mime.MimePart.Send(BaseWriter writer) at System.Net.Mime.MimeMultiPart.Send(BaseWriter writer) at System.Net.Mail.Message.Send(BaseWriter writer, Boolean sendEnvelope) at System.Net.Mail.MailMessage.Send(BaseWriter writer, Boolean sendEnvelope) at System.Net.Mail.SmtpClient.Send(MailMessage message) --- End of inner exception stack trace --- at System.Net.Mail.SmtpClient.Send(MailMessage message)
我在 google 中找到了一些类似的答案,但它不起作用。有人可以帮忙吗?我正在使用无法使用 SmtpClient.Dispose()
的 .NET 3.5
这是类似的问题:
我终于找到了问题的答案。它非常适合为以前的 .net 处理 smtpclient。
Does system.net.mail.smptclient disconnect from the server?
这是代码
var smtp = new SmtpClient();
smtp.ServicePoint.MaxIdleTime = 1;
smtp.ServicePoint.ConnectionLimit = 1;
smtp.Send(message);