In my ASP.net website i have done with sending email to users when they register their self but what i want that when a user register from my website it will automatically send email after 5 minutes instead of immediate sending after registration. Here is my simple code :
private void SendEmail()
{
SmtpClient smtpClient = new SmtpClient();
MailMessage mailMsg = new MailMessage();
MailAddress fromAddress = new MailAddress("test@test.com");
smtpClient.Host = "mail.test.com";
smtpClient.Credentials = new NetworkCredential("test@test.com", "test");
smtpClient.Port = 25;
mailMsg.From = fromAddress;
mailMsg.To.Add(emailid);
mailMsg.Subject = "You are successfully registered";
mailMsg.Body = myString.ToString();
mailMsg.IsBodyHtml = true;
smtpClient.Send(mailMsg);
System.Threading.Thread.Sleep(500000);
}
I used System.Threading.Thread.Sleep(50000) to wait for 5 minutes but this did not help me out to get my exact needs.
I am thinking that i need to set a flag in database table against every registered user email and i will make a webservice which will execute after 5 minutes to see which email addresses needs to be send an email . Is there any other little fast way to do this?