MX Records for resolving email address

  • Thread starter Ghislain Tanguay
  • 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
 
K

Ken Tucker [MVP]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top