Sample code for 30+ languages & platforms
Classic ASP

Transition from MailMan.MxLookup to Dns.Query

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

Chilkat Classic ASP Downloads

Classic ASP
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0

set mailman = Server.CreateObject("Chilkat.MailMan")

' ...
' ...

emailAddr = "joe@example.com"

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

domain = mailman.MxLookup(emailAddr)
If (mailman.LastMethodSuccess = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( mailman.LastErrorText) & "</pre>"
    Response.End
End If

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

set dns = Server.CreateObject("Chilkat.Dns")

set json = Server.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).
success = dns.Query("MX",emailAddr,json)
If (success = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( dns.LastErrorText) & "</pre>"
    Response.End
End If

i = 0
count_i = json.SizeOfArray("answer.mx")
Do While i < count_i
    json.I = i
    domain = json.StringOf("answer.mx[i].domain")
    Response.Write "<pre>" & Server.HTMLEncode( domain) & "</pre>"
    i = i + 1
Loop

%>
</body>
</html>