Friday, December 30, 2016

Validate Email Id in ax 2012

static boolean validateEmail(str _email)
{
    str emailAddressFilter = @"^[^@]+@[^@]+\.[^@]+$";
    System.Text.RegularExpressions.Regex regEx;
    System.Text.RegularExpressions.Match regMatch;
    str email;
    List emailAddresses;
    ListEnumerator enum;
    boolean retVal;
    regEx = new System.Text.RegularExpressions.Regex(emailAddressFilter);
    emailAddresses = SysEmailDistributor::splitEmail(_email);
    enum = emailAddresses.getEnumerator();
    while(enum.moveNext())
    {
        email = enum.current();
        if (email)
        {
            regMatch = regEx.Match(email);
            retVal = regMatch.get_Success();
        }
        else
            retVal = false;
        if(!retVal)
            break;
    }
    return retVal;
}

No comments:

Post a Comment

Copy Markup charges while posting purchase invoice using X++

 Copy Markup charges while posting purchase invoice using X++ Class: Important: Code logic is just for Reference.  New class => Duplicate...