28

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.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
JL.
  • 78,954
  • 126
  • 311
  • 459
  • Question was marked as community wiki - deleted and re-asked as a plain question. – JL. May 10 '10 at 13:58
  • @Slaks, no 3.5 is fine, except 3.5 SMTPClient implementation does not send a QUIT command to the SMTP server, so even once the object goes out of scope, and new instance of object is created, it continues on old exchange session meaning you hit send size limits quick, exchange defaults to 20MBs – JL. May 10 '10 at 14:00
  • @JL: I edited to remove the emotion - clearly there is a bug and Microsoft acknowledges that. The question now is how fast can we make them fix it. – John Saunders May 10 '10 at 14:02
  • @John, I take it by your edit of the question - you have indeed confirmed this to be a bug? – JL. May 10 '10 at 14:02
  • @JL: Microsoft has confirmed it to be a bug. – John Saunders May 10 '10 at 17:39

2 Answers2

29

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

Andy May
  • 4,030
  • 5
  • 34
  • 33
  • I ran this x64 hotfix on a few servers and it takes like 5 minutes to install this little 2MB patch. Any one else experience that? – Gordon Bell Oct 01 '10 at 15:49
  • 1
    It took a long time to install on my server as well. – Andy May Oct 01 '10 at 16:01
  • 2
    The link is dead and pretty much all search results links for "KB2183292". More information on the patch here (with broken links as well): https://support.microsoft.com/en-us/kb/2183292 – BrutalDev Apr 19 '15 at 12:03
  • I am also facing this issue. Let me install the patch and see if it works. – khichar.anil Jul 28 '15 at 15:55
  • I click on the link,but not able to download this patch.I did not found the link there. – Sumit Jambhale Nov 01 '17 at 10:46
  • You can find the update here https://support.microsoft.com/en-us/help/2468871/update-for-the-net-framework-4-march-2011 – Lucius Oct 30 '18 at 08:49
3

I installed the updates from http://support.microsoft.com/kb/2468871 in Windows 2008 R2. Planning to install it on Windows 2003 R2 SP2. The update was installed without much delay and it worked without a restart.

It replaces 2183292 (http://support.microsoft.com/kb/2183292/ ) FIX: "Failure sending mail" error message when you send an email message by using a .NET Framework 4-based application that uses the "System.Net.Mail.SmtpClient" class if the email attachment is larger than 3 MB

2413613 (http://support.microsoft.com/kb/2413613/ ) A shortcut menu may appear far away from the mouse pointer when you run a Windows Presentation Foundation application that is based on the .NET Framework 4

2298853 (http://support.microsoft.com/kb/2298853/ ) FIX: Visual Studio 2010 error: "Error 1 error MSB4014: The build stopped unexpectedly because of an internal failure"

2461678 (http://support.microsoft.com/kb/2461678/ ) A .NET Framework 4-based WPF application crashes if the source object of a data binding in a control is an element that is defined outside the name scope of the control

2484841 (http://support.microsoft.com/kb/2484841/[anySimpleType]/ ) FIX: A .NET Framework 4.0-based WPF application may stop responding if you right-click a control to open a pop-up control

Hope this helps.

Thanks, Raghav

Raghav
  • 31
  • 1