C# console app to send email at scheduled times

前端 未结 8 751
北海茫月
北海茫月 2020-12-28 18:44

I\'ve got a C# console app running on Windows Server 2003 whose purpose is to read a table called Notifications and a field called \"NotifyDateTime\" and send an email when

8条回答
  •  無奈伤痛
    2020-12-28 19:16

    If you know when the emails need to be sent ahead of time then I suggest that you use a wait on an event handle with the appropriate timeout. At midnight look at the table then wait on an event handle with the timeout set to expire when the next email needs to be sent. After sending the email wait again with the timeout set based on the next mail that should be sent.

    Also, based on your description, this should probably be implemented as a service but it is not required.

提交回复
热议问题