Validating email addresses in vb net
" Else If In Str(1, str Email, "@") = Len(str Email) Then Validate Email = False EMsg = EMsg & "Your @sign can not be the last character in your email address!
We will check email address throw the " web service.
If you have a need to validate a user input or string to ensure that only a valid email is entered , then you can use Regular Expressions or REGEX to handle that easily.
Then it extracts the domain from each address and performs different DNS lookups to ensure that the related domain exists and is configured to accept email messages.
After that, it checks an embedded database to find if that domain is a disposable email address (DEA) provider and reacts accordingly.
"End If End Function So this part looks for the @ on the first place of the string if the string is in the format @somthing then its not valide so that the funtion calls the goto funtion and moves to Not Valide Next Part like you see is This is a easy if stament we use the instr funtion to make a bool statment dont know the right word for it in english hope you know what i mean so if the instr funtion returns false we know that the @ is missing and this is again not a valide email address and we then call a msgbox to tell that the @ is missing Next Part is This is again a bool statment that looks for what the funtion returns if instr funtion returns false we know that a .
is missing so its not a valide email address if instr returns a true the .
While this validation isn't perfect and some dodgy emails will still slip through, it's a pretty good start.
It is completely written in managed code (C#) and is compliant with Common Language Specification (CLS), so it can be used with any other . NET), C /CLI, J#, Iron Python, Iron Ruby, F# and Power Shell.
Public Function Val Email(mail As String)If Left(mail, 1) = "@" Then Go To Not Valide Else If Right(mail, 1) = "@" Then Go To Not Valide Else If In Str(1, mail, "@") = False Then Msg Box "The @ is Missing!