Posted on: 1/28/2014 5:06:33 PM | Views : 611

Hello,
I have an app to send emails, lots of them. I use for sending System.Net.Mail, everything is fine until the last emails are sent... the app quit and do not wait for all responses to be received.
I use for sending:
SendingEmailsCounter++;
SentEmails++; client.SendCompleted += new SendCompletedEventHandler(client_SendCompleted);
client.SendAsync(message, string.Format("{0},{1}", from_, to_));

And the function wich is called at response;
void client_SendCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
{
ReceivedResponses++;
SendingEmailsCounter--;
}

And keep the thread alive using
Go to the complete details ...