There are n-number of ways to detect errors in email addresses; some use regular expressions to do that. The same has been built as a check in ASP.NET validation controls.
The following function uses the Try-Catch exception handling by assigning the address to the mail message. If the format of the email address is found to be wrong, then the function returns false. A simple one; please post your comments on the way it worksJ
Function Detect_MailAddress_Errors(ByVal sMailAdd As String) As Boolean
Try
Dim oMailMsg As New MailMessage
oMailMsg.To.Add(sMailAdd)
Return True
'Format Exceptions
Catch exFormat As FormatException
'MsgBox("Format Error")
Return False
' General Exceptions
Catch ex As Exception
End Try
End Function
Also consider this free component: http://www.info2000.biz/df_mailstuff
ReplyDeleteI found this library for verifying email addresses in .net:
ReplyDeletehttp://www.kellermansoftware.com/p-37-net-email-validation.aspx