BeginSendMail() private method

private BeginSendMail ( System.Net.Mail.MailAddress sender, MailAddressCollection recipients, string deliveryNotify, bool allowUnicode, AsyncCallback callback, object state ) : IAsyncResult
sender System.Net.Mail.MailAddress
recipients MailAddressCollection
deliveryNotify string
allowUnicode bool
callback AsyncCallback
state object
return IAsyncResult
Example #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);
         }
     }
 }
Example #2
0
        private void ConnectCallback(IAsyncResult result)
        {
            if (GlobalLog.IsEnabled)
            {
                GlobalLog.Enter("SmtpClient#" + LoggingHash.HashString(this) + "::ConnectCallback");
            }
            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);
            }

            if (GlobalLog.IsEnabled)
            {
                GlobalLog.Leave("SmtpClient#" + LoggingHash.HashString(this) + "::ConnectCallback");
            }
        }