Marvin kakuru

Marvin kakuru

  • 1.3k
  • 324
  • 155.1k

failure sending email

Nov 26 2019 7:50 AM
hi everyone
i have been sending emails successfuly using my windows application, but all of the sudden my application is failing to send emails and am getting an error
"unable to read data from transport connection: net_io_connetionclosed."
 
below is the code i have been using
 
         }
            string smtAddress = "smtp.mail.yahoo.com";
            int portNumber = 587;
            bool enableSSL = true;

            DateTime dat = DateTime.Parse(label55.Text.ToString());

            string emailFrom = "[email protected]";
            string password = "kyozimayenje";
            string emailTo = "[email protected]";
            string subject = dat.ToString("dd/MM/yyyy") + " - " + "Testing Bank Emailing System";
            string body = "Dear Customer Banking Emailing System Undergoing Testing";


            using (MailMessage mail = new MailMessage())
            {
                mail.From = new MailAddress(emailFrom);
                mail.To.Add(emailTo);
                mail.Subject = subject;
                mail.Body = body;
                mail.IsBodyHtml = true;

                //Attachments
                //mail.Attachments.Add(new Attachment("C:\\Import of Used clothing & stationary research.pdf"));

                SmtpClient smtp = new SmtpClient(smtAddress, portNumber);
                {
                    smtp.Credentials = new NetworkCredential(emailFrom, password);
                    smtp.EnableSsl = enableSSL;
                    smtp.Send(mail);
                }

            }
 any help will be greatly appreciated