Sample code for 30+ languages & platforms
Visual FoxPro

Transition from MailMan.MxLookupAll to the Chilkat DNS class

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

Chilkat Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loMailman
LOCAL lcEmailAddr
LOCAL loSa
LOCAL loDns
LOCAL loJson
LOCAL i
LOCAL lnCount_i
LOCAL lcDomain

lnSuccess = 0

loMailman = CreateObject('Chilkat.MailMan')

* ...
* ...

lcEmailAddr = "joe@example.com"

* ------------------------------------------------------------------------
* The MxLookupAll method is deprecated:

loSa = loMailman.MxLookupAll(lcEmailAddr)
IF (loMailman.LastMethodSuccess = 0) THEN
    ? loMailman.LastErrorText
    RELEASE loMailman
    CANCEL
ENDIF

* ...
* ...

RELEASE loSa

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

loDns = CreateObject('Chilkat.Dns')

loJson = CreateObject('Chilkat.JsonObject')

* This gets all MX domains for an email address.  (Typically one domain.)
* The preferred domain will be at index 0 (see below).
lnSuccess = loDns.Query("MX",lcEmailAddr,loJson)
IF (lnSuccess = 0) THEN
    ? loDns.LastErrorText
    RELEASE loMailman
    RELEASE loDns
    RELEASE loJson
    CANCEL
ENDIF

i = 0
lnCount_i = loJson.SizeOfArray("answer.mx")
DO WHILE i < lnCount_i
    loJson.I = i
    lcDomain = loJson.StringOf("answer.mx[i].domain")
    ? lcDomain
    i = i + 1
ENDDO

RELEASE loMailman
RELEASE loDns
RELEASE loJson