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.
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);
}
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~
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.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.