System.Net.Mail.SendMailAsyncResult.SendData C# (CSharp) Method

SendData() private method

private SendData ( ) : void
return void
        private void SendData()
        {
            IAsyncResult result = DataCommand.BeginSend(_connection, s_sendDataCompleted, this);
            if (!result.CompletedSynchronously)
            {
                return;
            }
            DataCommand.EndSend(result);
            _stream = _connection.GetClosableStream();
            if (_failedRecipientExceptions.Count > 1)
            {
                InvokeCallback(new SmtpFailedRecipientsException(_failedRecipientExceptions, _failedRecipientExceptions.Count == _toCollection.Count));
            }
            else if (_failedRecipientExceptions.Count == 1)
            {
                InvokeCallback(_failedRecipientExceptions[0]);
            }
            else
            {
                InvokeCallback();
            }
        }

Usage Example

 private static void SendToCollectionCompleted(IAsyncResult result)
 {
     if (!result.CompletedSynchronously)
     {
         SendMailAsyncResult asyncState = (SendMailAsyncResult)result.AsyncState;
         try
         {
             string str;
             if (!RecipientCommand.EndSend(result, out str))
             {
                 asyncState.failedRecipientExceptions.Add(new SmtpFailedRecipientException(asyncState.connection.Reader.StatusCode, asyncState.toCollection[asyncState.toIndex - 1].SmtpAddress, str));
                 if (asyncState.failedRecipientExceptions.Count == asyncState.toCollection.Count)
                 {
                     SmtpFailedRecipientException exception = null;
                     if (asyncState.toCollection.Count == 1)
                     {
                         exception = (SmtpFailedRecipientException)asyncState.failedRecipientExceptions[0];
                     }
                     else
                     {
                         exception = new SmtpFailedRecipientsException(asyncState.failedRecipientExceptions, true);
                     }
                     exception.fatal = true;
                     asyncState.InvokeCallback(exception);
                     return;
                 }
             }
             if (asyncState.SendToCollection())
             {
                 asyncState.SendData();
             }
         }
         catch (Exception exception2)
         {
             asyncState.InvokeCallback(exception2);
         }
     }
 }
All Usage Examples Of System.Net.Mail.SendMailAsyncResult::SendData