using System.Text.RegularExpressions;
public Boolean IsValidationEmail(string Email)
{
try
{
Regex reg = new Regex(@"^[a-zA-Z][\w\.-]{2,28}[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$");
if (Email.Length > 0)
{
MatchText(reg, Email, "Valid E-Mail expected");
return true;
}
else
{
throw new Exception("Email length is must be more then zero");
}
}
catch (Exception ex)
{
throw ex;
}
}
private Boolean MatchText(Regex reg, string EmailText, string Message)
{
try
{
if (!reg.IsMatch(EmailText))
{
throw new Exception("Please Check, Invalid Email");
}
else
{
return true;
}
}
catch (Exception ex)
{
throw ex;
}
}
No comments:
Post a Comment