Failure Sending Mail RRS feed

  • Question

  • I have an application in Vb 2013 and Net Framework 4.0. Users send e-mails with attachments less 500KB and cc it to multiple addresses.

    Its been working fine until about a month ago. Now every now and then we get an exception - Failure sending message. This happens on a couple of computers and the rest are fine. I just don't know what can be happening here. We have a mix of Win 7 and Win 8 systems.

    I understand it has something to do with Net Framework 4.0. My code has been working for years until I upgraded to Net 4.0 and this started happening. The strange part is some computers it works fine while others get this message.

    I have seen posts where MS know this is an issue on some computers and has a fix for it but cant get without paying for it. I need help with this.


    Sunil Prasad


    Tuesday, April 28, 2015 12:57 AM


  • Hello Sunil Prasad,

    >>The strange part is some computers it works fine while others get this message.

     Do you mean that some computers with .NET 4.0 installed could still work while some others also installed .NET 4.0 throw the failure sending mail? If so, I think this could be caused by machine environment, I suggest you could try to create visual machine with only .NET 4.0 installed and other components your application needs to check if it is caused by the .NET 4.0.

    You could also have a try to use a higher version .NET as 4.5 to see if this issue would go.

    Personally, I sent a mail with an image about 400KB by using both .NET 4.5 and .NET 4.0 SMTP api and it worked, here is the code you could have a try:

    static void Main(string[] args)
                    SmtpClient client = new SmtpClient();
                    client.Credentials = new System.Net.NetworkCredential("XXXX", "XXX");
                    client.EnableSsl = true;
                    client.Port = 587;
                    client.Host = "";
                    MailAddress from = new MailAddress("XXX");
                    MailAddress to = new MailAddress("XXX");
                    MailAddress ReplyTo = new MailAddress("XXXX");
                    MailMessage message = new MailMessage(from, to);
      MailAddress bcc = new MailAddress("XXXX");
                    message.Body = "This is a test e-mail message sent by an application. ";
                    message.BodyEncoding = System.Text.Encoding.UTF8;
                    message.Subject = "test message 1";
                    message.SubjectEncoding = System.Text.Encoding.UTF8;
                    string attachmentFilename = "New.jpg";
                    Attachment attachment = new Attachment(attachmentFilename, MediaTypeNames.Application.Octet);
                    ContentDisposition disposition = attachment.ContentDisposition;
                    disposition.CreationDate = File.GetCreationTime(attachmentFilename);
                    disposition.ModificationDate = File.GetLastWriteTime(attachmentFilename);
                    disposition.ReadDate = File.GetLastAccessTime(attachmentFilename);
                    disposition.FileName = Path.GetFileName(attachmentFilename);
                    disposition.Size = new FileInfo(attachmentFilename).Length;
                    disposition.DispositionType = DispositionTypeNames.Attachment;
                    client.SendCompleted += new
                    string userState = "test message1";
                    client.SendAsync(message, userState);
                    Console.WriteLine("Sending message... press c to cancel mail. Press any other key to exit.");
                    string answer = Console.ReadLine();
                    if (answer.StartsWith("c") && mailSent == false)
                catch (CryptographicException e1)
                catch (Exception e)
            private static void SendCompletedCallback(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
                mailSent = true;


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, April 29, 2015 5:49 AM