ComponentPro UltimateEmailValidator

      Localizing messages

      Language Filter: AllSend comments on this topic to ComponentPro

      From version 1.2, UltimateEmailValidator allows you to customize log messages showing while validating email addresses. By default, all messages are in English and loaded from the embedded resource of the UltimateEmailValidator assembly.

      To customize messages inside the UltimateEmailValidator, you can use property LocalizationSettings of UltimateEmailValidator class. There are a number of messages which represent stages in the validation process. For more information about this property you can refer to the Class Reference.

      The example below demonstrates how to localize log messages: 

      using System;
      using ComponentPro.Net;
      
      ...
      
      static void Main()
      {
          EmailValidator em = new EmailValidator();
      
          em.MessageLogging += em_MessageLogging;
          em.EmailValidated += em_EmailValidationCompleted;
      
          em.LocalizationSettings.CheckingEmailSyntaxString = "## Checking email syntax started";
          try 
          {
              em.Validate("test@somedomain.com");
          }
          catch (EmailValidatorException exc2)
          {
              Console.WriteLine("EmailValidatorException: " + exc2.Message);
          }
      }
      
      static void em_EmailValidationCompleted(object sender, EmailValidatedEventArgs e)
      {
          if (e.ValidatedLevel == ValidationLevel.Success)
              Console.WriteLine(e.EmailAddress + " validation done");
          else 
              Console.WriteLine(e.EmailAddress + " validation failed at " + e.ValidatedLevel.ToString());
      }
      
      static void em_MessageLogging(object sender, EmailValidatorLogEventArgs e)
      {
          Console.Write(e.SmtpTranscript);
      }