Click here to Skip to main content
15,918,333 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
please help,
dear friends i have developed a website in which i want to send a insurance reminders Email every day to all members , in the midnight even when no one is logged in the website.

so no one is calling the reminder function. it should be done periodically at every midnight.

Thanks in advance,
Rajkumar
Posted
Comments
bbirajdar 21-Nov-12 7:59am    
Use a windows service
rajkumar9867 21-Nov-12 8:01am    
can you give me an example please.
bbirajdar 21-Nov-12 8:05am    
http://www.codeproject.com/Articles/16335/Simple-Windows-Service-which-sends-auto-Email-aler
rajkumar9867 21-Nov-12 8:09am    
i want this for Asp.net and C#
bbirajdar 21-Nov-12 8:14am    
asp.net is not designed for scheduled tasks. You will have to use windows services or some third party tools like quartz.net http://quartznet.sourceforge.net/

1 solution

Do you have your SMTP code ready for sending email ? if NO then visit my this answer .

Before that do these:
1. Create a console application.
2. Write a code to fetch list of emails of all the user which are suppose to recieve those email. (in this you can provide filteration od users.)
3. Add this code to send email
C#
protected void SendMail()
{
    // Gmail Address from where you send the mail
    var fromAddress = "Gmail@gmail.com";
    // any address where the email will be sending
    var toAddress = YourEmail.Text.ToString(); 
    //Password of your gmail address
    const string fromPassword = "Password";
     // Passing the values and make a email formate to display
    string subject = YourSubject.Text.ToString();
    string body = "From: " + YourName.Text + "\n";
    body += "Email: " + YourEmail.Text + "\n";
    body += "Subject: " + YourSubject.Text + "\n";
    body += "Question: \n" + Comments.Text + "\n";
    // smtp settings
    var smtp = new System.Net.Mail.SmtpClient();
    {
        smtp.Host = "smtp.gmail.com"; // provide your smtpserver
        smtp.Port = 587;
        smtp.EnableSsl = true;
        smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
// provide your stmp server credentials
        smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
        smtp.Timeout = 20000;
    }
    // Passing values to smtp object
    smtp.Send(fromAddress, toAddress, subject, body);
}

4. Test it throughly.
5. build it in release mode.
6. Take the exe from your bin folder and add that into Schedule TASK of your server
7. If you dont know how to do it refer this : ..Schedule a Task[^]

8. Dont forget to mark it as answer if you have found it working for you
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900