The email regular expression function is used to determine whether the EMAIL is correct, so as to better send emails and notifications to users.
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)-faster Rev (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