Когда я пытаюсь отправить файл размером 100 МБ в качестве вложения электронной почты, я получаю исключение system.outofmemoryexception. С тем же кодом я смог отправить вложение размером 12 МБ
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 config file добавлены следующие строки
<system.web>
<httpRuntime targetFramework="4.6" maxRequestLength="2097152" />
</system.web>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2147483648" />
</requestFiltering>
</security>
</system.webServer>