Thursday, October 3, 2013

System.Net.Mail.SmtpException: Failure sending mail. —> System.IndexOutOfRangeException: Index was outside the bounds of the array.


            Attachment attachment = new Attachment(@"d:\4mb.dat");

            // This is the problem code, to workaround the issue make sure you are not using                         Base64 as encoding
            // attachment.TransferEncoding = System.Net.Mime.TransferEncoding.Base64;

            // Any of those two code section will work
            // attachment.TransferEncoding = System.Net.Mime.TransferEncoding.QuotedPrintable;

            attachment.TransferEncoding = System.Net.Mime.TransferEncoding.SevenBit;


            msg.Attachments.Add(attachment);

         
                         

      

No comments:

Post a Comment