How to implement bulk mailing using windows service on a schedule basis?

眉间皱痕 提交于 2019-12-13 05:41:50

问题


I've a requirement in which i need to send 10000+ mails on a quarterly basis. For this purpose i used a windows service that triggers every day and executes the mailing functionality only after the third month. I've to fetch last three months records from database and need to send one mail for each record.

The problem i faced was the mail server i used do not allow bulk mailing.

How can i do this effectively by providing a delay between each sent (20 mails per minute)?


回答1:


There are many way to archieve this. We once had a similar requirement and solved it via a home grown service, which would fetch items from a special database table (mail queue) and sent each mail individially. The queue is filled over time by regular business logic. The necessary locking can also be done via db: a SCHEDULE column stores the expected scheduled time of sending the mail. That way the service collects only those mails wich are 'ready' for sending. After successfull send, another column (SENT_TIMESTAMP) is used to mark the success.

We implemented the whole service in ASP and triggered it via regular Windows Task Planner jobs. In your case, the service would start every minute and the queue would provide the next 20 mails. An even easier way could be to utilize SQL Server Jobs. SQL Server is capable of delivering mails to a local SMTP server as well.

If not done yet, please note that SO question as well: What is the best way to send large batches of emails in ASP.NET?



来源:https://stackoverflow.com/questions/5630323/how-to-implement-bulk-mailing-using-windows-service-on-a-schedule-basis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!