在ASP.NET中发送大批邮件的最好方式是什么? [英] What is the best way to send large batches of emails in ASP.NET?
问题描述
我正在循环使用数据采集器,并调用System.Net.Mail.SmtpClient的Send()方法。这个问题就是这样很慢。每个电子邮件大约需要5-10秒钟发送(这可能是我的主机的一个问题)。我不得不覆盖我的web.config文件中的executionTimeout默认值(默认为90秒),如下所示:
I'm currently looping through a datareader and calling the System.Net.Mail.SmtpClient's Send() method. The problem with this is that it's slow. Each email takes about 5-10 seconds to send (it's possible this is just an issue with my host). I had to override the executionTimeout default in my web.config file (it defaults to 90 seconds) like this:
<httpRuntime executionTimeout="3000" />
一个警告:我在一个共享的主机上,所以我不认为这是可能的我使用PickupDirectoryFromIis选项发送(至少在我打开它时给我错误)。
One caveat: I'm on a shared host, so I don't think it is possible for me to send using the PickupDirectoryFromIis option (at least, it gave me errors when I turned it on).
推荐答案
你可以发送邮件异步。这样超时不应该中断你的发送。
You could send the mail asynchronous. That way the timeout should not interrupt your sending.
这篇文章应该可以帮助你开始:在C#中异步发送电子邮件。
This article should help you get started with that: Sending Emails Asynchronously in C#.
这里还有另一种方法: http://www.vikramlakhotia.com/Sending_Email_asynchronously_in_AspNet_20.aspx
There is another approach here: http://www.vikramlakhotia.com/Sending_Email_asynchronously_in_AspNet_20.aspx
当然还有几个商业客户端可用,但是我唯一一个可以推荐的商业客户端是 http:/ /www.aspnetemail.com/
And off course there are several commercial clients available, but the only one that i have tried and can recommend is http://www.aspnetemail.com/
这篇关于在ASP.NET中发送大批邮件的最好方式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!