Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 593
JL. Avatar asked May 10 '10 13:05

JL.


2 Answers

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

like image 174
Andy May Avatar answered Sep 22 '22 00:09

Andy May


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

like image 39
Raghav Avatar answered Sep 20 '22 00:09

Raghav