How do I validate email address formatting with the .NET Framework?

前端 未结 11 643
孤城傲影
孤城傲影 2020-11-29 05:49

I want a function to test that a string is formatted like an email address.

What comes built-in with the .NET framework to do this?

This works:



        
11条回答
  •  没有蜡笔的小新
    2020-11-29 06:19

        Public Function ValidateEmail(ByVal strCheck As String) As Boolean
            Try
                Dim vEmailAddress As New System.Net.Mail.MailAddress(strCheck)
            Catch ex As Exception
                Return False
            End Try
            Return True
        End Function
    

提交回复
热议问题