1

当我尝试将大小为 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>
4

0 回答 0