ComponentPro UltimateBounceInspector

      RejectedRecipient Event

      See AlsoMembers Options: Show AllLanguage Filter: AllSend comments on this topic to ComponentPro
      Occurs when a recipient is rejected by the server.

      Syntax

      public event EventHandler<TEventArgs> RejectedRecipient

      Examples

      Show how to handle the RejectedRecipient event.

      using System;
      using System.Windows.Forms;
      using ComponentPro.Net;
      using ComponentPro.Net.Mail;
      
      ...
      
      public void HandleRejectedRecipientEvent()
      {
          const string serverName = "myserver";
          const string user = "name@domain.com";
          const string password = "mytestpassword";
          const int port = 465;
          const SslSecurityMode securityMode = SslSecurityMode.Implicit;
      
          // Create a new instance. 
          Smtp client = new Smtp();
      
          client.RejectedRecipient += client_RejectedRecipient;
      
          try 
          {
              MailMessage mmMessage = new MailMessage();
              mmMessage.From.Add("from@thedomain.com");
              mmMessage.To.Add("name@domain.com");
              mmMessage.To.Add("someone@domain.com");
              mmMessage.CC.Add("someone2@domain.com");
              mmMessage.Bcc.Add("someone3@domain.com");
              mmMessage.Subject = "Test Subject";
              mmMessage.BodyText = "Test Content";
      
              Console.WriteLine("Connecting SMTP server: {0}:{1}...", serverName, port);
              // Connect to the server. 
              client.Connect(serverName, port, securityMode);
      
              // Login to the server. 
              Console.WriteLine("Logging in as {0}...", user);
              client.Authenticate(user, password);
      
              Console.WriteLine("Sending mail message...");
              client.Send(mmMessage);
              Console.WriteLine("Message sent...");
      
              // Disconnect. 
              Console.WriteLine("Disconnecting...");
              client.Disconnect();
          }
          catch (SmtpException smtpExc)
          {
              MessageBox.Show(string.Format("An SMTP error occurred: {0}, ErrorStatus: {1}", smtpExc.Message, smtpExc.Status));
          }
          catch (Exception exc)
          {
              MessageBox.Show(string.Format("An error occurred: {0}", exc.Message));
          }
      
          // ... 
       
          // Disconnect. 
          client.Disconnect();
      }
      
      void client_RejectedRecipient(object sender, SmtpRejectedRecipientEventArgs e)
      {
          Console.WriteLine("Recipient rejected: " + e.Recipient);
      }

      Framework

      .NET Compact Framework.NET Compact Framework

      Supported version: 2.0, 3.5, and 3.9
      Assembly: ComponentPro.Mail.CF (in ComponentPro.Mail.CF.dll)

      .NET Framework.NET Framework

      Supported version: 2.0, 3.0, 3.5, 4.0, 4.5.x, 4.6.x and later
      Assembly: ComponentPro.Mail (in ComponentPro.Mail.dll)

      Xamarin AndroidXamarin Android

      Supported version: 2.3 and later
      Assembly: ComponentPro.Mail.Android (in ComponentPro.Mail.Android.dll)

      Xamarin MacXamarin Mac

      Supported version: 2.0.x and later
      Assembly: ComponentPro.Mail.Mac (in ComponentPro.Mail.Mac.dll)

      Xamarin iOSXamarin iOS

      Supported version: 5.1.x and later
      Assembly: ComponentPro.Mail.iOS (in ComponentPro.Mail.iOS.dll)

      See Also