System.Net.Mail.SmtpTransport.BeginSendMail C# (CSharp) Method

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
        internal IAsyncResult BeginSendMail(MailAddress sender, MailAddressCollection recipients,
            string deliveryNotify, bool allowUnicode, AsyncCallback callback, object state)
        {
            if (sender == null)
            {
                throw new ArgumentNullException(nameof(sender));
            }

            if (recipients == null)
            {
                throw new ArgumentNullException(nameof(recipients));
            }

            SendMailAsyncResult result = new SendMailAsyncResult(_connection, sender, recipients,
                allowUnicode, _connection.DSNEnabled ? deliveryNotify : null,
                callback, state);
            result.Send();
            return result;
        }

Usage Example

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);
         }
     }
 }
All Usage Examples Of System.Net.Mail.SmtpTransport::BeginSendMail