private static void SendDataCompleted(IAsyncResult result)
{
if (!result.CompletedSynchronously)
{
SendMailAsyncResult thisPtr = (SendMailAsyncResult)result.AsyncState;
try
{
DataCommand.EndSend(result);
thisPtr._stream = thisPtr._connection.GetClosableStream();
if (thisPtr._failedRecipientExceptions.Count > 1)
{
thisPtr.InvokeCallback(new SmtpFailedRecipientsException(thisPtr._failedRecipientExceptions, thisPtr._failedRecipientExceptions.Count == thisPtr._toCollection.Count));
}
else if (thisPtr._failedRecipientExceptions.Count == 1)
{
thisPtr.InvokeCallback(thisPtr._failedRecipientExceptions[0]);
}
else
{
thisPtr.InvokeCallback();
}
}
catch (Exception e)
{
thisPtr.InvokeCallback(e);
}
}
}