我一直在尝试使用C#ASP.NET 3.5 System.Net.Mail发送一个大附件(9 MB)。我读到.NET 4.0有一个不允许这样的bug,但.NET 3.5很好。 .NET 4.0 Fails When sending emails with attachments larger than 3MB
由于.NET 3.5在发送电子邮件后没有正确关闭会话,因此我在发送电子邮件之前添加了该行:
smtpClient.ServicePoint.MaxIdleTime = 2;
该行
smtpClient.Send(email);
仍在抛出此错误:
Exceeded storage allocation. The server response was: 5.3.4 Error: message file too big:
at System.Net.Mail.DataStopCommand.CheckResponse(SmtpStatusCode statusCode, String serverResponse)
at System.Net.Mail.DataStopCommand.Send(SmtpConnection conn)
at System.Net.Mail.SmtpConnection.OnClose(Object sender, EventArgs args)
at System.Net.ClosableStream.Close()
at System.Net.Mail.MailWriter.Close()
at System.Net.Mail.SmtpClient.Send(MailMessage message)
更改编码没有用。这会破坏附件:
email.Attachments[0].TransferEncoding = System.Net.Mime.TransferEncoding.SevenBit;
有人可以帮忙吗?谢谢。
答案 0 :(得分:4)
服务器响应是:5.3.4错误:消息文件太大:
它告诉您需要知道的一切:服务器不允许发送该大小的附件。您的代码没有任何问题,至少不是因为.NET中的错误或类似的错误。您链接的与.NET中的错误相关的错误消息与您获得的错误消息非常不同。这是无关的。