ComponentPro UltimateEmailValidator

      Displaying progress while validating e-mails

      Language Filter: AllSend comments on this topic to ComponentPro

      When the email list to validate is long and your application may take time to validate all e-mails, you may wish to show the progress of the validation to the user. The UltimateEmailValidator component provides progress notification through the Progress event. The Progress event is raised periodically while e-mail validation is in progress, making accessible necessary data to display progress information, such as e-mail address and validation level.

      The following steps show you how to use the Progress event to show progress information while validating e-mail addresses:

      Displaying progress while validating e-mail addresses

      1. Add using directives to your code to create aliases for existing namespaces and avoid having to type the fully qualified type names. The code looks similar to the following:
        using System;
        using ComponentPro.Net;
        
      2. Create a new instance of the EmailValidator class.
        EmailValidator em = new EmailValidator();
        
      3. Now pass the e-mail list file you want to validate to the ValidateTextFile method. The code looks similar to the following:
        // Register an event handler.
        em.Progress += em_Progress;
        
        try
        {
            em.ValidateTextFile("c:\\EmailList.txt");
        }
        catch (EmailValidatorException exc2)
        {
            Console.WriteLine("EmailValidatorException: " + exc2.Message);
        }
        

      Final example code

      using System;
      using ComponentPro.Net;
      
      ...
      
      static void Main()
      {
          EmailValidator em = new EmailValidator();
      
          // Register an event handler. 
          em.Progress += em_Progress;
      
          try 
          {
              em.ValidateTextFile("c:\\EmailList.txt");
          }
          catch (EmailValidatorException exc2)
          {
              Console.WriteLine("EmailValidatorException: " + exc2.Message);
          }
      }
      
      static void em_Progress(object sender, EmailValidatorProgressEventArgs e)
      {
          Console.WriteLine("Validating email '{0}' at level {1}. Completed {2}%", e.EmailAddress, e.Level.ToString(), e.ProgressPercentage);
      }