Sunday, 23 September 2012

Validate Email address


/// <summary>
///    This method accepts a EMail and validates this using REGEX
/// </summary>
/// <returns>
///    true or false based on Regex match
/// </returns>
public  boolean validateEMail(EMail    _eMail)
{

    boolean valid;
    Boolean   xppBool;
    System.Boolean netBool;
    Str MatchEmailPattern =
       @"^(([\w-]+\.)+[\w-]+|([a-zA-Z]{1}|[\w-]{2,}))@"
     + @"((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?
       [0-9]{1,2}|25[0-5]|2[0-4][0-9])\."
     + @"([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?
       [0-9]{1,2}|25[0-5]|2[0-4][0-9])){1}|"
     + @"([a-zA-Z]+[\w-]+\.)+[a-zA-Z]{2,4})$";
    System.Text.RegularExpressions.Match myMatch;
    new InteropPermission(InteropKind::ClrInterop).assert();
    myMatch = System.Text.RegularExpressions.Regex::Match(_eMail,MatchEmailPattern);
    netBool = myMatch.get_Success();
    xppBool = netBool;
    CodeAccessPermission::revertAssert();
    Return xppBool;
}

2 comments:

  1. I am really surprised for this website. Just now i have visit this website then i got information about validate email address. I hope next time here i will found some valuable information about email list cleaning service . So please keep it up.........

    ReplyDelete