Sample code for 30+ languages & platforms
VB.NET

Transition from MailMan.MxLookup to Dns.Query

Provides instructions for replacing deprecated MxLookup method calls with the Chilkat Dns class.

Chilkat VB.NET Downloads

VB.NET
Dim success As Boolean = False

Dim mailman As New Chilkat.MailMan

' ...
' ...

Dim emailAddr As String = "joe@example.com"

' ------------------------------------------------------------------------
' The MxLookup method is deprecated:

Dim domain As String = mailman.MxLookup(emailAddr)
If (mailman.LastMethodSuccess = False) Then
    Debug.WriteLine(mailman.LastErrorText)
    Exit Sub
End If


' ------------------------------------------------------------------------
' Do the equivalent using the Chilkat DNS class

Dim dns As New Chilkat.Dns

Dim json As New Chilkat.JsonObject

' This gets all MX domains for an email address.  (Typically one domain.)
' The preferred domain will be at index 0 (see below).
success = dns.Query("MX",emailAddr,json)
If (success = False) Then
    Debug.WriteLine(dns.LastErrorText)
    Exit Sub
End If


Dim i As Integer = 0
Dim count_i As Integer = json.SizeOfArray("answer.mx")
While i < count_i
    json.I = i
    domain = json.StringOf("answer.mx[i].domain")
    Debug.WriteLine(domain)
    i = i + 1
End While