FIX: "Failure sending mail" error message when you send an email message by using a .NET Framework 4.0-based application that uses the "System.Net.Mail.SmtpClient" class if the email attachment is larger than 3 MB

SYMPTOMS
Consider the following scenario:
  • You run a .NET Framework 4.0-based application. This application uses the System.Net.Mail.SmtpClient class to send email messages.
  • You add an attachment that meets the following conditions to an email message.
    • The TransferEncoding property in the attachment is not specified. Or, the TransferEncoding property is specified as Base64 or Unknown.
    • The size of the attachment is larger than 3 MB.
  • You send the email message.
In this scenario, a System.Net.Mail.SmtpException exception and a System.IndexOutOfRangeException inner exception are generated. Additionally, you receive the following error message:
Failure sending mail.
The following is the error message for the inner exception:
Index was outside the bounds of the array.
RESOLUTION

Hotfix information

A supported hotfix is now available from Microsoft. However, it is intended to correct only the problem that this article describes. Apply it only to systems that are experiencing this specific problem.

To resolve this problem, contact Microsoft Customer Support Services to obtain the hotfix. For a complete list of Microsoft Customer Support Services telephone numbers and information about support costs, visit the following Microsoft website:Note In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question.

Note To download this hotfix, you can also visit the following Microsoft website: 

Prerequisites

You must have .NET Framework 4.0 installed to apply this hotfix.

Restart requirement

You do not have to restart the computer after you apply this hotfix if no affected file is being used.

Hotfix replacement information

This hotfix does not replace any other hotfixes.

File information

The English version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in Coordinated Universal Time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time item in Control Panel.
File information for all x86-based versions of Windows XP, of Windows Server 2003, of Windows Vista, of Windows Server 2008, of Windows 7, and of Windows Server 2008 R2
File nameFile versionFile sizeDateTimePlatform
SetupUi.dll10.0.30319.335295,24813-Jul-201006:36x86
Setupengine.dll10.0.30319.335809,30413-Jul-201006:36x86
Setup.exe10.0.30319.33578,15213-Jul-201006:36x86
System.dll4.0.30319.3353,482,44013-Jul-201011:48x86
File information for all x64-based versions of Windows XP, of Windows Server 2003, of Windows Vista, of Windows Server 2008, of Windows 7, and of Windows Server 2008 R2
File nameFile versionFile sizeDateTimePlatform
SetupUi.dll10.0.30319.335295,24813-Jul-201006:36x86
Setupengine.dll10.0.30319.335809,30413-Jul-201006:36x86
Setup.exe10.0.30319.33578,15213-Jul-201006:36x86
System.dll4.0.30319.3353,482,44013-Jul-201011:48x86
File information for all IA-64-based versions of Windows XP, of Windows Server 2003, of Windows Vista, of Windows Server 2008, of Windows 7, and of Windows Server 2008 R2
File nameFile versionFile sizeDateTimePlatform
SetupUi.dll10.0.30319.335295,24813-Jul-201006:36x86
Setupengine.dll10.0.30319.335809,30413-Jul-201006:36x86
Setup.exe10.0.30319.33578,15213-Jul-201006:36x86
System.dll4.0.30319.3353,482,44013-Jul-201011:48x86
System.resources.dll4.0.30319.335217,44013-Jul-201006:36x86
WORKAROUND
To work around this issue, use one of the following methods:
  • Specify the TransferEncoding property as QuotedPrintable or SevenBit. For example, add one of the following lines of code into the application:
    • attachment.TransferEncoding = System.Net.Mime.TransferEncoding.QuotedPrintable;
    • attachment.TransferEncoding = System.Net.Mime.TransferEncoding.SevenBit;
    Note This method may not work in every case because the SevenBit encoding and the QuotedPrintable encoding may corrupt the attachments, and because the QuotedPrintable encoding may double the size of the attachment.
  • Send only an attachment that is smaller than 3 MB.
STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.
REFERENCES
For more information about the SmtpClient class, visit the following Microsoft Developer Network (MSDN) website:For more information about the TransferEncoding property, visit the following MSDN website:For more information about software update terminology, click the following article number to view the article in the Microsoft Knowledge Base:
824684 Description of the standard terminology that is used to describe Microsoft software updates
MORE INFORMATION
To reproduce this issue, run the following code:
using System.Net.Mail;static void Main(string[] args){    SmtpClient client = new SmtpClient("Your mail server");    client.Credentials = new System.Net.NetworkCredential("User", "Password", "Domain");    MailMessage msg = new MailMessage("Send From", "Send To", "Large Attachment Mail", "Large Attachment - Test Body");     Attachment attachment = new Attachment(@"<attachment file>");     msg.Attachments.Add(attachment);    client.Send(msg);    msg.Dispose();    msg = null;    client = null;}
Proprietà

ID articolo: 2183292 - Ultima revisione: 08/24/2010 09:01:00 - Revisione: 2.0

  • Microsoft .NET Framework 4
  • kbqfe kbhotfixserver kbfix kbexpertiseadvanced KB2183292
Feedback