I want the vb.net code(asp.net 2.0) for validating multiple email address in a textbox(multiline).

Life is the only God....OSHO

- Anup

Recommended Answers

All 8 Replies

I am a c# programmer I give some idea

01)get text box value to the string & split it to separate email address using split() function in string class
via spaces
eg-> iamchamith@yahoo.com [space] iamkasun@yahoo.com
arr[0] = iamchamith@yahoo.com
arr[1] = imakasun@yahoo.com

02)then get this values[each email addresses] to the array

03)now u can validate is each array(email address) correct using this method

04)In that case you check index of @ mark & . mark ...

05)Now You can validate it
[id index of @ small than index of . the email is correct]


Yes you can follow the steps that iamchamith said. After getting individaul email then you can validate those from the following URL:


This will just check the input format. If you are looking to test that email id really exist or not then you can try with VRFY(most mail server admin disables this feature for spammers) function of SMTP. For more details read rfc of SMTP.

Try string.Split should work. If you want validate you can write a regex for the same. Thanks.

Private Function ValidateEmail(ByVal EmailAddress As String) As Boolean
            If EmailAddress.Trim.Length = 0 Then
                MsgBox("Please enter the email Address")
                Return False
            End If
            Dim pattern As String = "^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"

            Dim emailAddressMatch As Match = Regex.Match(EmailAddress, pattern)
            If emailAddressMatch.Success Then
                Return True
                MsgBox("Please enter the valid email address")
                Return False
            End If

        Catch ex As Exception

        End Try
    End Function

Pass each email adress from array to this function and it will return true or false

The question was he wants to read emails from multiline text box and not the email validation i think

But he has mentioned like
I want the vb.net code(asp.net 2.0) for validating multiple email address in a textbox(multiline).

dai burger boy it's not working da

 <asp:RequiredFieldValidator ID="rfvEmailId" runat="server" 
                    ErrorMessage="Enter your city" ControlToValidate="txtEmailId" 
                    Display="Dynamic" ValidationGroup="RegisterButton" >*</asp:RequiredFieldValidator>
                         <asp:RegularExpressionValidator ID="revEmail" runat="server" 
                             ControlToValidate="txtEmailId" ErrorMessage="Invalid Email Id" 
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.