Tuesday, October 25, 2016

Check Valid Email from String c#

Hi All,

Please find the Code for Checking Valid Email from String

bool getValidationChecked = checkValidEmail(test@test.com);

public static bool checkValidEmail(string emailID)
        {
            bool validEmailAddress = false;
            string[] arrayAdditionalTo = emailID.Split(';');
            foreach (string word in arrayAdditionalTo)
            {
                string pattern = null;
                pattern = "^([0-9a-zA-Z]([-\\.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{2,9})$";

                if (Regex.IsMatch(word, pattern))
                {
                    validEmailAddress = true;
                }
                else
                {
                    return false;
                }
            }
            if (validEmailAddress)
            {
                return true;
            }
            return false;
}

No comments:

Post a Comment

How to Run Microsoft Flow for Every one Month

Introduction: In this Blog we will see how to Run Microsoft Flow for Every one Month. Implementation Steps:   1. Navigate to  https://make.p...