Esempio n. 1
0
 private void ConnectCallback(IAsyncResult result)
 {
     if (NetEventSource.IsEnabled)
     {
         NetEventSource.Enter(this);
     }
     try
     {
         _transport.EndGetConnection(result);
         if (_cancelled)
         {
             Complete(null, result);
         }
         else
         {
             // Detected durring Begin/EndGetConnection, restrictable using DeliveryFormat
             bool allowUnicode = IsUnicodeSupported();
             ValidateUnicodeRequirement(_message, _recipients, allowUnicode);
             _transport.BeginSendMail(_message.Sender ?? _message.From, _recipients,
                                      _message.BuildDeliveryStatusNotificationString(), allowUnicode,
                                      new AsyncCallback(SendMailCallback), result.AsyncState);
         }
     }
     catch (Exception e)
     {
         Complete(e, result);
     }
     finally
     {
         if (NetEventSource.IsEnabled)
         {
             NetEventSource.Exit(this);
         }
     }
 }