Function AvalMail (ByVal EAddress As String) As Boolean' Variáveis dimensionadas.Const AllowChars = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz._-"Dim UserName As StringDim ServerName As StringDim x As LongDim i As Integer'Validate email address.Let x = InStr(1, EAddress, "@")If x = 0 Then GoTo BadAddressIf InStr(x + 1, EAddress, "@") > 0 Then GoTo BadAddressLet UserName = Left$(EAddress, x - 1)Let ServerName = Right$(EAddress, Len(EAddress) - x)If Left$(UserName, 1) = "." Or Right$(UserName, 1) = "." Then GoTo BadAddressIf Left$(ServerName, 1) = "." Or Right$(ServerName, 1) = "." Or InStr(1, ServerName, ".") = 0 Then GoTo BadAddressFor i = 1 To Len(UserName)If InStr(1, AllowChars, Mid$(UserName, i, 1)) = 0 Then GoTo BadAddressNextFor i = 1 To Len(ServerName)If InStr(1, AllowChars, Mid$(ServerName, i, 1)) = 0 Then GoTo BadAddressNextLet AvalMail = TrueExit FunctionBadAddress:Let AvalMail = FalseEnd Function
References:
Tags: VBA, Tips, email, validade, avalia, checa, valida
Tags: VBA, Tips, email, validade, avalia, checa, valida