Why can SmtpClient.SendAsync only be called once?

前端 未结 7 1321
暗喜
暗喜 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:54

    I think you misunderstand the XXXAsync class of methods. The purpose of these asynchronous calls is to allow the program to continue running, without the need of the method to finish processing and return first. You can then proceed with the result later by subscribe to something like XXXReceived event of the object.

    To send more than one mail simultaneously, you may consider using more Threads.

提交回复
热议问题