Ho trovato e riadattato questa semplice funzione che dato un indirizzo mail, ne estrapola il dominio e verifica l'esistenza di un mail server.codice:Public Function ValidateMailServer(ByVal strEmail As String) As Boolean Dim posAt Dim sDomain As String posAt = InStr(1, strEmail, "@") If posAt > 0 Then sDomain = Mid(strEmail, posAt + 1, Len(strEmail) - posAt) Else sDomain = "" End If Dim mailserver As String = "" If sDomain <> "" Then Dim info As New ProcessStartInfo Dim ns As Process info.UseShellExecute = False info.RedirectStandardInput = True info.RedirectStandardOutput = True info.FileName = "nslookup" info.Arguments = "-type=MX " + sDomain.ToUpper.Trim ns = Process.Start(info) Dim sout As StreamReader sout = ns.StandardOutput Dim reg As Regex = New Regex("mail exchanger = (?<server>[^\\\s]+)") Dim response As String = "" Do While (sout.Peek() > -1) response = sout.ReadLine() Dim amatch As Match = reg.Match(response) If (amatch.Success) Then mailserver = amatch.Groups("server").Value Exit Do End If Loop End If If mailserver.Length <> 0 Then Return True Else Return False End If End Function
Pensate ci siano casi in qui non funzioni?
Attendo conferme.
ciao ciao


Rispondi quotando