si sono certo che la tua soluzione sia più concreta e funzionale della mia che è molto dispendiosa in termini di codice e ho visto qualche volta essere un po' carognetta.
quindi ti sottopongo uno spezzone del codice dove dovrei introdurre la funzione che hai proposto x vedere se ho ben capito il tutto.
codice:
if (NomeDest2<>"") and (Dest2<>"") then
'controllo inizialmente la presenza della @
if instr(1,cstr(Dest2),"@")>0 then
'estraggo la parte a sinistra e quella a destra della @
dim parteSinistra, parteDestra
parteSinistra=""
parteSinistra=Left(Cstr(Dest2),instr(1,cstr(Dest2),"@")-1)
parteDestra=""
parteDestra=Right(Cstr(Dest2),Len(Cstr(Dest2))-instr(1,cstr(Dest2),"@"))
'effettuo i controlli su queste due parti
if (cstr(parteSinistra)<>"") and (cstr(parteDestra)<>"") then
'controllo la presenza del . nella parte destra
if instr(1,cstr(parteDestra),".")<>0 then
'controllo la poszione del .
if cint(instr(1,cstr(Request("email")),"."))<>cint(instr(1,cstr(Request("email")),"@"))+1 then
'estraggo il testo alla destra del .
dim parteDestraPunto
parteDestraPunto=""
parteDestraPunto=Right(Cstr(parteDestra),Len(Cstr(parteDestra))-instr(1,cstr(parteDestra),"."))
'controllo cosa mi rappresenta questo testo
if (parteDestraPunto<>"co.uk") and (parteDestraPunto<>"us") and (parteDestraPunto<>"net") and (parteDestraPunto<>"it") and (parteDestraPunto<>"com") and (parteDestraPunto<>"org") and (parteDestraPunto<>"eu") and (parteDestraPunto<>"biz") and (parteDestraPunto<>"info") Then
flag=7
end if
else
flag=6
end if
else
flag=5
end if
else
flag=4
end if
else
flag=3
end if
Destinatario2=Dest2
NomeDestinatario2=NomeDest2
end if
in breve io in dest2 ho l'indirizzo mail del destinatario, quello da controllare
io dovrei sostutuire tutto il mio codice con il tuo e quindi
codice:
Function isValidEmail(argEmail)
isValidEmail = False
Dim Reg
Set Reg = New RegExp
Reg.Global = True
Reg.Ignorecase = True
Reg.pattern = "^([a-z][a-z.\d-_]*)?[a-z\d]\@[a-z][a-z.\d-_]*\.[a-z]+$"
if Reg.Test(argEmail) then isValidEmail = True
set Reg = Nothing
End Function
if (NomeDest2<>"") and (Dest2<>"") then
pippo=sValidEmail(Dest2)
if (pippo)=true then
flag=0
else
flag=1
end if
Destinatario2=Dest2
NomeDestinatario2=NomeDest2
end if
ciao e grazie