![]() |
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) MX Lookup Mail Server Domain by Email AddressHow to find the mail server for a given email address. Returns the domain name of the primary mail server. Note: This example requires Chilkat v11.0.0 or greater.
#include <C_CkDnsW.h> #include <C_CkJsonObjectW.h> void ChilkatSample(void) { BOOL success; HCkDnsW dns; HCkJsonObjectW json; const wchar_t *emailAddr; int i; int count_i; const wchar_t *domain; success = FALSE; // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. dns = CkDnsW_Create(); json = CkJsonObjectW_Create(); emailAddr = L"bob@example.com"; // 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)); 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; } CkDnsW_Dispose(dns); CkJsonObjectW_Dispose(json); } |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.