.NET 4.0 Fails When sending emails with attachments larger than 3MB

JL. picture JL. · May 10, 2010 · Viewed 13.8k times · Source

I recently had an issue after upgrading my .net framework to 4.0 from 3.5:

System.Net.Mail.SmtpException: Failure sending mail. ---> System.IndexOutOfRangeException: Index was outside the bounds of the array. at System.Net.Base64Stream.EncodeBytes(Byte[] buffer, Int32 offset, Int32 count, Boolean dontDeferFinalBytes, Boolean shouldAppendSpaceToCRLF) at System.Net.Base64Stream.Write(Byte[] buffer, Int32 offset, Int32 count) at System.Net.Mime.MimePart.Send(BaseWriter writer) at System.Net.Mime.MimeMultiPart.Send(BaseWriter writer) at System.Net.Mail.Message.Send(BaseWriter writer, Boolean sendEnvelope) at System.Net.Mail.SmtpClient.Send(MailMessage message) --- End of inner exception stack trace ---

I read this connect bug listing here: http://connect.microsoft.com/VisualStudio/feedback/details/544562/cannot-send-e-mails-with-large-attachments-system-net-mail-smtpclient-system-net-mail-mailmessage.

If anyone cares about this issue, please vote for it on Connect, so it will be fixed sooner.

Answer

Andy May picture Andy May · Sep 8, 2010

The bug has been patched: https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=30226

Title: KB2183292

Release Date: 7/21/2010

Size: 8.58 MB

Version: Hotfix

Category: Build

Description QFE: System.Net.Mail - SmtpClient class throws exceptions if file attachment is > over 3MB