I am using RegularExpressionValidator to validate EmailID where ValidateExpresion is::


Actually i want to validate EmailID that can also contain spaces.


< raman@gmail.com >,<raman@gmail.com>,< raman@gmail.com>
I want to validate all of the above Email IDs as Valid.

Please help me

Thanks in advance

Member Avatar

\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)* \w+([-.]\w+)

try this

I think you should split on comma and remove spaces, '<' and '>' to get a better validation.

Just a thought...

If CheckEmailList("< email@someplace.com >, < email2@someplace.com>") Then
              ' your code here for success
        End If

    Private Function CheckEmailList(ByVal sEmilList As String) As Boolean
        Dim bRet As Boolean = True
        Dim sList() As String = sEmilList.Split(",")
        Dim sEmail As String

        For Each sEmail In sList
            sEmail = sEmail.Replace("<", "").Replace(">", "").Replace(" ","")
            If isValidEmail(sEmail) = False Then bRet = False

        Return bRet
    End Function

    Public Function isValidEmail(ByVal EmailAddress As String) As Boolean

        Dim strRegex As String = "^([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})(\]?)$"
        Dim re As System.Text.RegularExpressions.Regex = New System.Text.RegularExpressions.Regex(strRegex)
        If re.IsMatch(EmailAddress) Then
            Return True
            Return False
        End If
    End Function