![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Unicode C) Transition from MailMan.MxLookup to Dns.QueryProvides instructions for replacing deprecated MxLookup method calls with the Chilkat Dns class. Note: This example requires Chilkat v11.0.0 or greater.
#include <C_CkMailManW.h> #include <C_CkDnsW.h> #include <C_CkJsonObjectW.h> void ChilkatSample(void) { HCkMailManW mailman; const wchar_t *emailAddr; const wchar_t *domain; HCkDnsW dns; HCkJsonObjectW json; BOOL success; int i; int count_i; mailman = CkMailManW_Create(); // ... // ... emailAddr = L"joe@example.com"; // ------------------------------------------------------------------------ // The MxLookup method is deprecated: domain = CkMailManW_mxLookup(mailman,emailAddr); if (CkMailManW_getLastMethodSuccess(mailman) == FALSE) { wprintf(L"%s\n",CkMailManW_lastErrorText(mailman)); CkMailManW_Dispose(mailman); return; } // ------------------------------------------------------------------------ // Do the equivalent using the Chilkat DNS class dns = CkDnsW_Create(); json = CkJsonObjectW_Create(); // This gets all MX domains for an email address. (Typically one domain.) // The preferred domain will be at index 0 (see below). success = CkDnsW_Query(dns,L"MX",emailAddr,json); if (success == FALSE) { wprintf(L"%s\n",CkDnsW_lastErrorText(dns)); CkMailManW_Dispose(mailman); CkDnsW_Dispose(dns); CkJsonObjectW_Dispose(json); return; } i = 0; count_i = CkJsonObjectW_SizeOfArray(json,L"answer.mx"); while (i < count_i) { CkJsonObjectW_putI(json,i); domain = CkJsonObjectW_stringOf(json,L"answer.mx[i].domain"); wprintf(L"%s\n",domain); i = i + 1; } CkMailManW_Dispose(mailman); CkDnsW_Dispose(dns); CkJsonObjectW_Dispose(json); } |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.