最好的方法,发送大量电子邮件? [英] Best way, to send large volumes of emails?

查看:344
本文介绍了最好的方法,发送大量电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


首先,即时通讯不是垃圾邮件.我想编写一个应用程序,为金融公司发送大量电子邮件-用于发送信息电子邮件.

该应用程序将是Windows窗体或Windows服务(发送保存在db中的电子邮件).

Hi,
First of all, im not spamming. I want to write an application, sending large volumes of email for financial companies - for sending information emails.

The application will be windows forms or windows service (sending emails saved in db).
What is the best way (not the easiest), to do that?

推荐答案

Windows服务!

阅读这些文章.

使用窗口服务发送批量电子邮件 [使用具有多个线程的C#发送大量电子邮件 [具有C#、. NET 2.0和Microsoft®SQL Server 2005 Service Broker的即用型群发电子邮件功能 [ ^ ]
Windows Services!

Read these articles.

Sending Bulk Emails using Window-services[^]

Send Mass Email in C# with Multiple Threads[^]

Ready-to-use Mass Emailing Functionality with C#, .NET 2.0, and Microsoft® SQL Server 2005 Service Broker[^]


首先,您必须有一个用于电子邮件的存储".
它可能是消息队列或数据库.
不要尝试循环发送大量eamils-这将无法正常工作.
然后,您需要Windows服务.
服务将唤醒,例如每30秒唤醒一次(您可能并且应该编写一个算法来确定服务唤醒的频率,具体取决于等待发送的电子邮件的数量),然后查询存储"以获取接下来的100封电子邮件(我是使用100,但仍然可以进行优化),发送电子邮件并进入睡眠状态.您可以通过在.config文件中定义电子邮件服务器并将其数据加载到服务"OnStart"方法上来增强服务.如果您有多个电子邮件服务,则可以为每个电子邮件服务创建一个单独的线程,并在线程之间划分电子邮件批次(我们的100个项目).
另外,请记住,电子邮件服务器可能会限制从单个IP地址发送的电子邮件数量.这是为了防止垃圾邮件.
您必须确保这不会影响您的服务.
最后但并非最不重要的一点是,为了使服务稳定可靠,有可能为由于某些错误而无法发送的eamils添加其他消息队列或db表.该服务将具有separte方法,该方法可能会得到
每15分钟触发一次说,以查看这些有问题的电子邮件并尝试再次发送.
First off you have to have a "storage" for emails.
It could be a message queueu or database.
Do not try to send large number of eamils in a loop - it will not work.
Then, you need a windows service.
The service will wake up, say every 30 seconds (you may and should write an algorithm for how often the service wakes up depending on the number of emails waiting to be sent), query the "storage" for say next 100 emails (I am using 100 but this still could be optimizied), send emails and go into sleep. You can enhance the service by defining email server(s) in .config file and loading their data on service "OnStart" method. If you have more than one email service you could create a separate thread for each and divide email batch (our 100 items) between threads.
Also, keep in mind that email server may have a limit on number of emails sent from single IP address; this is to defend against spamming.
You will have to make sure that this is not affecting your service.
Last but not least, to make the service robust, it may make sense to add additional message queue or db table for eamils which where not send due to some errors. The service would have a separte method which could get
triggered say every 15 minutes to peek at these problem emails and attempt to send it again.


使用System.Net.Mail命名空间并利用与邮件功能相关的任何类.例如,可以在此处找到从MSDN MailMessage类 [
Use System.Net.Mail namespace and utilize any classes that are associated with mail functionality.E.g can be found here from MSDN MailMessage Class[^]

I hope this will help you well.


这篇关于最好的方法,发送大量电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆