Sample code for 30+ languages & platforms
PowerBuilder

Transition from MailMan.MxLookup to Dns.Query

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

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Mailman
string ls_EmailAddr
string ls_Domain
oleobject loo_Dns
oleobject loo_Json
integer i
integer li_Count_i

li_Success = 0

loo_Mailman = create oleobject
li_rc = loo_Mailman.ConnectToNewObject("Chilkat.MailMan")
if li_rc < 0 then
    destroy loo_Mailman
    MessageBox("Error","Connecting to COM object failed")
    return
end if

// ...
// ...

ls_EmailAddr = "joe@example.com"

// ------------------------------------------------------------------------
// The MxLookup method is deprecated:

ls_Domain = loo_Mailman.MxLookup(ls_EmailAddr)
if loo_Mailman.LastMethodSuccess = 0 then
    Write-Debug loo_Mailman.LastErrorText
    destroy loo_Mailman
    return
end if

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

loo_Dns = create oleobject
li_rc = loo_Dns.ConnectToNewObject("Chilkat.Dns")

loo_Json = create oleobject
li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject")

// This gets all MX domains for an email address.  (Typically one domain.)
// The preferred domain will be at index 0 (see below).
li_Success = loo_Dns.Query("MX",ls_EmailAddr,loo_Json)
if li_Success = 0 then
    Write-Debug loo_Dns.LastErrorText
    destroy loo_Mailman
    destroy loo_Dns
    destroy loo_Json
    return
end if

i = 0
li_Count_i = loo_Json.SizeOfArray("answer.mx")
do while i < li_Count_i
    loo_Json.I = i
    ls_Domain = loo_Json.StringOf("answer.mx[i].domain")
    Write-Debug ls_Domain
    i = i + 1
loop


destroy loo_Mailman
destroy loo_Dns
destroy loo_Json