我正在尝试使用 SmtpClient 在 .NET 中编写一个通知服务(为了完全合法的非垃圾邮件目的)。最初我只是遍历每条消息并发送它,但是这很慢,我想提高速度。因此,我改用“SendAsync”,但现在在第二次调用时出现以下错误:
An asynchronous call is already in progress.
我读到这意味着 MS 削弱了 System.Net.Mail 以防止群发邮件。这个对吗?如果是这样,是否有更好的方法在 .NET 中执行此操作,并且仍然能够记录每封电子邮件的结果(这对我们的客户很重要)。如果不是,为什么 SendAsync 只能调用一次?
最佳答案
根据documentation :
After calling SendAsync, you must wait for the e-mail transmission to complete before attempting to send another e-mail message using Send or SendAsync.
所以要同时发送多封邮件你需要多个 SmtpClient 实例。
关于c# - 为什么 SmtpClient.SendAsync 只能调用一次?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/389709/