Click here to Skip to main content
13,143,637 members (29,483 online)
Rate this:
Please Sign up or sign in to vote.
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,
Posted 21-Nov-12 1:58am
aspnet_regiis -i 21-Nov-12 7:59am
Use a windows service
rajkumar9867 21-Nov-12 8:01am
can you give me an example please.
aspnet_regiis -i 21-Nov-12 8:05am
rajkumar9867 21-Nov-12 8:09am
i want this for and C#
aspnet_regiis -i 21-Nov-12 8:14am is not designed for scheduled tasks. You will have to use windows services or some third party tools like
sinhasourabh 21-Nov-12 8:14am
I will suggest use Schedule Task feature of windows. do don't want to execute it 24x7. it should be done periodically at every midnight so a schedule task will be better option.
sinhasourabh 21-Nov-12 8:35am
Sometimes i got amazed to see ppl downvoting a good answer :P . I would like them to 1st Read ENTIRE answer and then if they think something is not perfect then 'Let discuss it' and along with them we do have 'Improve Answer' option.I dont have issue in discussing because i am here to share rather than competeing I know from where the mentality of 'Pulling Legs to come up' had came ...
Sastry_kunapuli 21-Nov-12 9:54am
@sinhasourabh the answer is good,but what good is it to the question ?the question wanted to know how to automate the e-mailing process,response was on how send the it not a little bit off the path of the question ? probably you would have highlighted the scheduling task and then given the response of the code

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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
protected void SendMail()
    // Gmail Address from where you send the mail
    var fromAddress = "";
    // 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 = ""; // 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

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.170915.1 | Last Updated 21 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100