Why can SmtpClient.SendAsync only be called once?

前端 未结 7 1391
暗喜
暗喜 2021-02-02 11:22

I\'m trying to write a notification service (for completely legit non-spam purposes) in .NET using SmtpClient. Initially I just looped through each message and sent it, however

7条回答
  •  终归单人心
    2021-02-02 11:41

    You might be able to use the following:

    ThreadPool.QueueUserWorkItem(state => client.Send(msg));
    

    This should allow your messages to be queued and sent as threads become available.

提交回复
热议问题