简体   繁体   English

如何在C#中使用Windows Service安排电子邮件任务?

[英]How to schedule an email task using windows service in C#?

I'm creating a notification task. 我正在创建一个通知任务。 I have a web interface to create the task. 我有一个网络界面来创建任务。 So, I have two tables, one is NotificationToBeReleased and the other one is Notifications. 所以,我有两个表,一个是NotificationToBeReleased,另一种是通知。 I want to run a windows service on the server to find all the deliveryDate and start sending email to the users and delete the row from NotificationToBeReleased and enter into Notifications table. 我想在服务器上运行Windows服务以查找所有deliveryDate并开始向用户发送电子邮件,然后从NotificationToBeReleased中删除该行,然后输入Notifications表。

I'm new to this, good basic start would help me a lot! 我是新手,良好的基础入门对我有很大帮助! or Any suggestion also welcome. 或任何建议也欢迎。

For firing scheduled tasks, take a look at Quartz.net . 要触发计划任务,请查看Quartz.net

For small notification projects the solution you suggested, polling a database for delivery dates, will work up to a point. 对于小型通知项目,建议的解决方案(轮询数据库以获取交货日期)将在一定程度上起作用。 The problem comes when you need to check any issues. 当您需要检查任何问题时,问题就来了。 What happens if the email fails to be sent for example? 例如,如果电子邮件发送失败,该怎么办? Should it leave the row there and keep checking every minute. 它是否应该将行留在那里并保持每分钟检查一次。 What if the email did actually go out but we failed to clear the row. 如果电子邮件确实发送出去但我们无法清除该行怎么办。 The user gets swamped with emails. 用户被电子邮件淹没。

If you are after scalabilty, polling a database for notifications to send can become an issue. 如果您追求可扩展性,则轮询数据库以获取要发送的通知可能会成为问题。 Better to use an enterprise message queue solution . 最好使用企业消息队列解决方案。 Database as queue anti-pattern 数据库作为队列反模式

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM