主页 > 知识库 > 如何判断电子邮件的地址格式是否正确?

如何判断电子邮件的地址格式是否正确?

热门标签:自适应地图标注 重庆400电话哪里办理 辽宁营销智能外呼系统价格多少 武汉如何办理400电话 400电话是怎么申请 语音电销机器人视频 推销电话机器人怎么打电话的 教育机构地图标注 常州智能外呼电销机器人如何

第一种办法:

%

Function IsValidEmail(Email)

ValidFlag = False

If (Email > "") And (InStr(1, Email, "@") > 0) And (InStr(1, Email, ".") > 0) Then

atCount = 0

SpecialFlag = False

For atLoop = 1 To Len(Email)

atChr = Mid(Email, atLoop, 1)

If atChr = "@" Then atCount = atCount + 1

If (atChr >= Chr(32)) And (atChr = Chr(44)) Then SpecialFlag = True

If (atChr = Chr(47)) Or (atChr = Chr(96)) Or (atChr >= Chr(123)) Then SpecialFlag = True

If (atChr >= Chr(58)) And (atChr = Chr(63)) Then SpecialFlag = True

If (atChr >= Chr(91)) And (atChr = Chr(94)) Then SpecialFlag = True

Next

If (atCount = 1) And (SpecialFlag = False) Then

BadFlag = False

tAry1 = Split(Email, "@")

UserName = tAry1(0)

DomainName = tAry1(1)

If (UserName = "") Or (DomainName = "") Then BadFlag = True

If Mid(DomainName, 1, 1) = "." then BadFlag = True

If Mid(DomainName, Len(DomainName), 1) = "." then BadFlag = True

ValidFlag = True

' 格式正确返回Ture

End If

End If

If BadFlag = True Then ValidFlag = False

' 格式不正确返回False

IsValidEmail = ValidFlag

End Function

%>

 

    第二种办法:

%
function IsValidEmail(email)

dim names, name, i, c

IsValidEmail = true
names = Split(email, "@")
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(email, "..") > 0 then
  IsValidEmail = false
end if

end function
%>

   
第三种办法,用下面这个函数进行判断。它会检查邮件地址是否含有“@”,以及“.”是否在@”后面:

function isEmail(pInString)

  lAt = False
  lDot = false

  for x = 2 to len(pInstring)-1
    if mid(pInString,x,1) = "@" then lAt = True
      if mid(pInString,x,1) = "." and lAt = True then lDot = True
  next

  if lAt = True and lDot = True then
    isEmail = True
  else
    isEmail = False
  end if
end function

 

[1]

标签:中山 鸡西 邯郸 柳州 襄阳 威海 朔州 遵义

巨人网络通讯声明:本文标题《如何判断电子邮件的地址格式是否正确?》,本文关键词  如何,判断,电子邮件,的,;如发现本文内容存在版权问题,烦请提供相关信息告之我们,我们将及时沟通与处理。本站内容系统采集于网络,涉及言论、版权与本站无关。
  • 相关文章
  • 下面列出与本文章《如何判断电子邮件的地址格式是否正确?》相关的同类信息!
  • 本页收集关于如何判断电子邮件的地址格式是否正确?的相关信息资讯供网民参考!
  • 推荐文章