A perfect ASP verification email email Code

Source: Internet
Author: User
Tags email string valid email address

Dim webname,weburl,filepath,language,errortext
' Check to see if the email format is correct
function IsValidEmail (email)
Dim names,name,i,c
Isvalidemail=true
' Use the @ character to divide the email string into substrings and save them in the names array
Names=split (email, "@")
The ' UBound function returns the largest subscript of the array names, UBound (names) <>1 indicates that the @ character exists in the email string
' Not a, so email is not a valid email address format
If UBound (names) <>1 then
Isvalidemail=false
Exit function
End If
For each element in the array names of each name in names '
Number of characters within the If Len (name) <=0 Then ' string name
Isvalidemail=false
Exit function
End If
For I=1 to Len (name)
' Mid ' returns the name,i,1 character in the string name, which is converted to lowercase by the LCase function
C=lcase (Mid (name,i,1))
The ' InStr function returns the position of the first occurrence of a string in another string.
' InStr ("abcdefghijklmnopqrstuvwxyz_-.", c) <=0 indicates that character C is not a string
' "abcdefghijklmnopqrstuvwxyz_-." , IsNumeric (c) determines whether the character C is a number
If InStr ("abcdefghijklmnopqrstuvwxyz_-.", c) <=0 and not IsNumeric (c) Then ' does not support Chinese format addresses
Isvalidemail=false
Exit function
End If
Next
' Left (name,1) returns the leftmost character of the string name. Right (name,1) returns the rightmost character of the string name
If left (name,1) = "." or Right (name,1) = "." Then
Isvalidemail=false
Exit function
End If
Next
If InStr (Names (1), ".") <=0 Then ' email string @ The right part of @ does not contain characters '.
Isvalidemail=false
Exit function
End If
The ' InStrRev function returns the position of a string that appears from the end in another string,
' InStrRev (names (1), ".") Get the character "." The position from the end of the string names (1)
I=len (names (1))-InStrRev (names (1), ".")
' E-mail is last generally CN or COM, with a length of 2 or 3
If I<>2 and i<>3 then
Isvalidemail=false
Exit function
End If
' There is a string in the email ' ... '
If InStr (email, "...") >0 Then
Isvalidemail=false
End If
End Function

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.