Why can SmtpClient.SendAsync only be called once?

前端 未结 7 1327
暗喜
暗喜 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:35

    As noticed by everyone else here, you can only send one email at a time, but the way to send another once the first has been sent is to handle the .SendCompleted event of the SmtpClient class, and then move on to the next email and send that.

    If you want to send many emails simultaneously, then as the others have said, use multiple SmtpClient objects.

提交回复
热议问题