MX Records for resolving email address

  • Thread starter Thread starter Ghislain Tanguay
  • Start date Start date
G

Ghislain Tanguay

Hi everyone,
this is the code I use now for resolving domain address with email. But I
use an external program "nslookup" to verify my addresses.

Is there an intrinsic object in dotnet who do the same job?

Dim objInfoProc As New ProcessStartInfo
Dim objProc As Process
Dim objStdOut As StreamReader
Dim reg As Regex
Dim mailserver As String
Dim response As String = ""
Dim amatch As Match
Dim strDom As String()
Dim blnDomTrouv As Boolean = False

strDom = _strAdrCourl.Split("@"c)
objInfoProc.UseShellExecute = False
objInfoProc.RedirectStandardInput = True
objInfoProc.RedirectStandardOutput = True
objInfoProc.FileName = "nslookup"
objInfoProc.Arguments = "-type=MX " + strDom(1).ToUpper.Trim
objProc = Process.Start(objInfoProc)

objStdOut = objProc.StandardOutput
reg = New Regex("mail exchanger = (?<server>[^\\\s]+)")

Do While (objStdOut.Peek() > -1)
response = objStdOut.ReadLine()
amatch = reg.Match(response)
If (amatch.Success) Then
mailserver = amatch.Groups("server").Value
blnDomTrouv = True
Exit Do
End If
Loop
Return blnDomTrouv
 
Hi,

There is no built in function. Here is a dll written by Carl
Frankins that does that.

http://www.franklins.net/dotnet/MailChecker.zip

Ken
-------------------
message Hi everyone,
this is the code I use now for resolving domain address with email. But I
use an external program "nslookup" to verify my addresses.

Is there an intrinsic object in dotnet who do the same job?

Dim objInfoProc As New ProcessStartInfo
Dim objProc As Process
Dim objStdOut As StreamReader
Dim reg As Regex
Dim mailserver As String
Dim response As String = ""
Dim amatch As Match
Dim strDom As String()
Dim blnDomTrouv As Boolean = False

strDom = _strAdrCourl.Split("@"c)
objInfoProc.UseShellExecute = False
objInfoProc.RedirectStandardInput = True
objInfoProc.RedirectStandardOutput = True
objInfoProc.FileName = "nslookup"
objInfoProc.Arguments = "-type=MX " + strDom(1).ToUpper.Trim
objProc = Process.Start(objInfoProc)

objStdOut = objProc.StandardOutput
reg = New Regex("mail exchanger = (?<server>[^\\\s]+)")

Do While (objStdOut.Peek() > -1)
response = objStdOut.ReadLine()
amatch = reg.Match(response)
If (amatch.Success) Then
mailserver = amatch.Groups("server").Value
blnDomTrouv = True
Exit Do
End If
Loop
Return blnDomTrouv
 
Back
Top