When i'm trying to send a file which is of size 100mb as email attachment, i'm getting system.outofmemoryexception. With the same code i was able to send the attachment which is having size of 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);
}
And in wed config file added following lines
<system.web>
<httpRuntime targetFramework="4.6" maxRequestLength="2097152" />
</system.web>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2147483648" />
</requestFiltering>
</security>
</system.webServer>