while (true) { System.Threading.Thread.Sleep(1); ReadInput(); Application.DoEvents(); MailMessage mail = new MailMessage(); SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com"); System.Threading.Thread.Sleep(2000); mail.From = new MailAddress(""); mail.To.Add(""); mail.Subject = "Test Mail"; mail.Attachments.Add(new System.Net.Mail.Attachment("C://Users//matte//test.txt")); mail.Body = "This is for testing SMTP mail from GMAIL"; SmtpServer.Port = 587; SmtpServer.Credentials = new System.Net.NetworkCredential("", ""); SmtpServer.EnableSsl = true; SmtpServer.Send(mail); System.Threading.Thread.Sleep(10000); }
I tried an cooldown but the email is keeping sending without sleep how can i do that that every 30 minutes the email get sendet??