Sending mail periodically in ASP.net
<p>I'm trying to send confirmation mails to users periodically in ASP.NET. </p>

<p>To do this I polulate a queue with mails and check it every 30 seconds. Any confirmation emails in the queue at this time are sent and then cleared from the queue. </p>

<p>Does anyone know how to do this? </p>

<p>Here is my sending mail code</p>

<pre><code>public static bool SendMail(string AdminMail,string AdminPassword,string subject,string toAddress, string content,DateTime SendTime)
        {
            toAddressListProperty.Enqueue(toAddress);

            if(date==null)
            {
                date = DateTime.Now.Second;
            }
            if (date-SendTime.Second &gt; 120)
            {
                    var message = new MailMessage
                                      {
                                          From = new MailAddress(AdminMail)
                                      };

                    foreach (var toAddressl in toAddressListProperty)
                    {
                        message.To.Add(new MailAddress(toAddressl));
                    }

                    message.Subject = subject;
                    message.Body = content;
                    message.IsBodyHtml = true;
                    var smtp = new SmtpClient
                                   {
                                       Credentials = new System.Net.NetworkCredential(AdminMail, AdminPassword),
                                       Port = 587,
                                       Host = "smtp.gmail.com",
                                       EnableSsl = true
                                   };
                    smtp.Send(message);
                //date = SendTime;
                return true;
            }
            return false;
        }
</code></pre>
