简体   繁体   English

使用C#ASP.NET 3.5 System.Net.Mail发送大附件

[英]sending big attachments using C# ASP.NET 3.5 System.Net.Mail

I have been trying to send a big attachment (9 MB) using C# ASP.NET 3.5 System.Net.Mail. 我一直在尝试使用C#ASP.NET 3.5 System.Net.Mail发送大附件(9 MB)。 I read that .NET 4.0 had a bug which doesn't allow this, but .NET 3.5 is fine. 我读到.NET 4.0有一个不允许这样做的错误,但是.NET 3.5很好。 .NET 4.0 Fails When sending emails with attachments larger than 3MB .NET 4.0在发送附件大于3MB的电子邮件时失败

Since .NET 3.5 doesn't close the session properly after an email is sent, I added this line before it's sent: 由于.NET 3.5在发送电子邮件后无法正常关闭会话,因此在发送之前添加了以下行:

    smtpClient.ServicePoint.MaxIdleTime = 2; 

The line 线

    smtpClient.Send(email);

is still throwing this error: 仍然抛出此错误:

    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)

Changing the encoding doesn't help. 更改编码无济于事。 This corrupts the attachment: 这会破坏附件:

    email.Attachments[0].TransferEncoding = System.Net.Mime.TransferEncoding.SevenBit;

Could someone please help? 有人可以帮忙吗? Thank you. 谢谢。

The server response was: 5.3.4 Error: message file too big: 服务器响应为:5.3.4错误:消息文件太大:

That tells you everything you need to know: The Server dissallows sending attachments of that size. 这告诉您您需要了解的所有信息: 服务器不允许发送该大小的附件。 There's nothing wrong with your code, at least not because of a bug in .NET or something like that. 您的代码没有任何问题,至少不是因为.NET中的错误或类似问题。 The error message you link related to a bug in .NET is very different from what you are getting. 您链接的与.NET中的错误相关的错误消息与所获得的错误消息完全不同。 It's unrelated. 没关系

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM