0

How to verify email address whether exist or not in asp c#?
I have search google about it, but there are no one clear's solution..

I need all help!!!
Thank You.

2
Contributors
3
Replies
10
Views
5 Years
Discussion Span
Last Post by Mitja Bonca
0

Hi, check here:

public bool IsValidEmail(string emailAddress)
  {
       if (string.IsNullOrEmpty(emailAddress)) { return false; }

       string _emailPattern = @"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*";
       return new Regex(_emailPattern).Match(_emailPattern).Success;
  }
//OR:
private bool ValidatingEmail(string inputEmail)
        {
            string strRegex = @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" +
                  @"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" +
                  @".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";
            Regex re = new Regex(strRegex);
            if (re.IsMatch(inputEmail))
                return (true);
            else
                return (false);
        }
0

Hi~ Thanks for the reply:)


I have some question want to ask. First is is it this code you provide is to validate email address exist at mail server or not? Second is this code is put at where? Is it put at after i double click email textbox at .cs file there ?

Thank You~

0

This code is for email validation. That means that it checks if email is correctly written, so if it is written in correct form only. Method returns true if all ok, and false if email is not in correct form.
You can call this method when ever you want.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.