Marvin kakuru

Marvin kakuru

  • 1.4k
  • 359
  • 160.8k

Sending email from Windows form application

Aug 2 2016 7:56 AM
Hi everyone, I hv been using the code below to send emails with much success but now it doesn't work any more. Any help will be much appreciated. Code public void SendEmail() { try { SmtpClient clientSMTP = new SmtpClient("smtp.gmail.com", 587); clientSMTP.EnableSsl = true; clientSMTP.DeliveryMethod = SmtpDeliveryMethod.Network; clientSMTP.UseDefaultCredentials = false; clientSMTP.Credentials = new NetworkCredential("[email protected]", "password"); using(MailMessage message = new MailMessage()) { message.From = new MailAddress("yourgmailid @gmail.com"); message.Subject = "Subject"; message.IsBodyHtml = true; message.To.Add("[email protected]"); message.Body = "Hi " + "Suresh" + "!\n" + "Welcome to C# Corner!" + "Please click here to activate your account. \nThanks!"; clientSMTP.Send(message); } } catch (Exception ex) {} finally {}

Answers (9)