private bool SendToCollection()
 {
     while (this.toIndex < this.toCollection.Count)
     {
         string           str;
         MultiAsyncResult result = (MultiAsyncResult)RecipientCommand.BeginSend(this.connection, this.toCollection[this.toIndex++].SmtpAddress + this.deliveryNotify, sendToCollectionCompleted, this);
         if (!result.CompletedSynchronously)
         {
             return(false);
         }
         if (!RecipientCommand.EndSend(result, out str))
         {
             this.failedRecipientExceptions.Add(new SmtpFailedRecipientException(this.connection.Reader.StatusCode, this.toCollection[this.toIndex - 1].SmtpAddress, str));
         }
     }
     return(true);
 }
Example #2
0
 private void SendToCollection()
 {
     while (_toIndex < _toCollection.Count)
     {
         MultiAsyncResult result = (MultiAsyncResult)RecipientCommand.BeginSend(_connection,
                                                                                _toCollection[_toIndex++].GetSmtpAddress(_allowUnicode) + _deliveryNotify,
                                                                                s_sendToCollectionCompleted, this);
         if (!result.CompletedSynchronously)
         {
             return;
         }
         string response;
         if (!RecipientCommand.EndSend(result, out response))
         {
             _failedRecipientExceptions.Add(new SmtpFailedRecipientException(_connection.Reader.StatusCode,
                                                                             _toCollection[_toIndex - 1].GetSmtpAddress(_allowUnicode), response));
         }
     }
     SendData();
 }
 private void SendTo()
 {
     if (this.to != null)
     {
         IAsyncResult result = RecipientCommand.BeginSend(this.connection, (this.deliveryNotify != null) ? (this.to + this.deliveryNotify) : this.to, sendToCompleted, this);
         if (result.CompletedSynchronously)
         {
             string str;
             if (!RecipientCommand.EndSend(result, out str))
             {
                 throw new SmtpFailedRecipientException(this.connection.Reader.StatusCode, this.to, str);
             }
             this.SendData();
         }
     }
     else if (this.SendToCollection())
     {
         this.SendData();
     }
 }