Validar correo electrónico en C#

        /// <summary>
        /// Método para validar si una cadena cumple con la condición de ser correo electrónico.
        /// </summary>
        /// <param name="value">Valor a validar.</param>
        /// <returns>Resultado de la validación.</returns>
        public bool ValidateEmail(string value)
        {
            bool result = false;

            try
            {
                MailAddress mailAddress = new MailAddress(value);
                result = mailAddress.Address.Equals(value, StringComparison.OrdinalIgnoreCase);
            }
            catch (Exception)
            {
                result = false;
            }

            return result;
        }

 

Comentarios (1) -

  • 937303 40503i was just browsing along and came upon your internet site. just wantd to say wonderful job and this post genuinely helped me. 57308

Agregar comentario

Loading