- by JL
I recently had an issue after upgrading my .net framework to 4.0 from 3.5, I did this because in 4.0 the SMTPClient finally sends a QUIT command to the SMTP server.
However recently I was most disturbed to run into a base64 decoding issue, when sending out emails with attachments larger than 3MB's using .net v4 smtpclient:
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
and also this bug listing here: http://connect.microsoft.com/VisualStudio/feedback/details/102644/system-net-mail-fails-to-send-index-was-outside-the-bounds-of-the-array
So my question is - is .net 4.0 RTM really not capable of such an easy task as sending a message with an attachment larger than 3MB's?