当我尝试发送大小为100mb的文件作为电子邮件附件时,我正在获取system.outofmemoryexception。使用相同的代码,我可以发送大小为12mb的附件
using (var sendemail = new SmtpClient())
{
//code with smtp host, To address etc goes here
sendemail.Timeout = 500000;
msg.Attachments.Add(new
System.Net.Mail.Attachment(@"C:\data.zip")); //data.zip is the attachment stored on my C drive
sendemail.Send(msg);
}
然后在wed配置文件中添加了以下几行
<system.web>
<httpRuntime targetFramework="4.6" maxRequestLength="2097152" />
</system.web>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2147483648" />
</requestFiltering>
</security>
</system.webServer>