ITPub博客

首页 > IT基础架构 > 网络安全 > 判断字符串是否是合法的EMail (转)

判断字符串是否是合法的EMail (转)

原创 网络安全 作者:amyz 时间:2007-10-14 15:25:35 0 删除 编辑
判断字符串是否是合法的EMail (转)[@more@]

Public Function IsValideMail(stremail As String) As Boolean
  Dim names, name, i, c
  IsValidEmail = True
 
  names = Split(strEmail, "@")

  If UBound(names) <> 1 Then
  IsValidEmail = False
  Exit Function
  End If

  For Each name In names

  If Len(name) <= 0 Then
  IsValidEmail = False
  Exit Function
  End If

  For i = 1 To Len(name)
  c = LCase(Mid(name, i, 1))

  If InStr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 And Not IsNumeric(c) Then
  IsValidEmail = False
  Exit Function
  End If
  Next

  If Left(name, 1) = "." Or Right(name, 1) = "." Then
  IsValidEmail = False
  Exit Function
  End If

  Next

  If InStr(names(1), ".") <= 0 Then
  IsValidEmail = False
  Exit Function
  End If

  i = Len(names(1)) - InStrRev(names(1), ".")

  If i <> 2 And i <> 3 Then
  IsValidEmail = False
  Exit Function
  End If

  If InStr(strEmail, "..") > 0 Then
  IsValidEmail = False
  Exit Function
  End If

End Function


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10752019/viewspace-976605/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
  • 博文量
    3984
  • 访问量
    7373788