System.Net.Mail.MailAddress允许电子邮件地址中的逗号?

时间:2012-12-02 04:50:06

标签: asp.net email

最近,我更新了一些代码以使用System.Net.Mail.MailAddress()来检查电子邮件地址是否有效。不久之后,我注意到一些域名中带有逗号的电子邮件地址被认为是有效的,例如,下面的代码将表明电子邮件地址是有效的???

好悲伤! - 你们其他人怎么处理这个?

dim ok as Boolean

dim test_str as String = "someone@comma,com"

dim email as System.Net.Mail.MailAddress

ok = true

Try 
   email = new System.Net.Mail.MailAddress( test_str )
Catch ex As Exception
   ok = false
End Try   

if ( ok ) then
   response.write( "Valid" )
else
   response.write( "INVALID" )
end if

0 个答案:

没有答案