Alex Rivera | Logout

Why can SmtpClient.SendAsync only be called once?

Asked 2008-12-23T18:38:00.233
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 this is slow and I would like to improve the speed. So, I switched to using 'SendAsync', but now get the following error on the second call:

An asynchronous call is already in progress. 

I read this to mean that MS crippled System.Net.Mail to prevent mass-mailers. Is this correct? If so, is there a better way to do this in .NET, and still be able to log the results of each email(which is important to our client). If not, why can SendAsync only be called once?

Edit
Report

1 Answer

2

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.

answered 2008-12-23T18:52:16.757

Your Answer