CDnsClient::EnumMailExchanges
INT EnumMailExchanges(
LPCTSTR lpszHostName,  
LPTSTR *lpszMailExchanges,  
INT nMaxMailExchanges  
);

The EnumMailExchanges method returns a list of mail exchanges for the specified host name or IP address.

Parameters

lpszHostName
Pointer to the string that contains the hostname or domain name to be queried.
lpszMailExchanges
Pointer to an array of string pointers which specify one or more mail exchanges. If the application needs to store these values, a local copy should be made because they are invalidated when another host name is resolved. The list of mail exchange records is sorted in priority order, from highest (i.e., those whose preference value is smallest) to lowest.
nMaxMailExchanges
The maximum number of mail exchanges in the array. If this parameter is 0, then the method will return the number of mail exchanges, but the list of mail exchanges will not be output in lpszMailExchanges.

Return Value

If the method succeeds, the return value is the number of mail exchanges. If the method fails, the return value is DNS_ERROR. To get extended error information, call GetLastError.

Example

    // Get the number of mail exchanges
    if ((nMX = pClient->EnumMailExchanges(szHostName, NULL, 0)) == DNS_ERROR)
    {
        pClient->ShowError();
    }
    else
    {
        // Allocate memory for the list of mail exchanges
        lpszMailExchanges = (LPTSTR *)LocalAlloc(LPTR, (nMX * sizeof(LPTSTR)));
        // Retrieve the list of mail exchanges
        nMX = pClient->EnumMailExchanges(szHostName, lpszMailExchanges, nMX);

        // Populate a listbox with the mail exchanges
        for (int nIndex = 0; nIndex < nMX; nIndex++)
             pListBox->AddString(*lpszMailExchanges++);

        LocalFree((HLOCAL)lpszMailExchanges);
    }

Requirements

Client: Requires Windows Vista, Windows XP or Windows 2000 Professional.
Server: Requires Windows Server 2008, Windows Server 2003 or Windows 2000 Server.
Header: Include cstools6.h.
Library: Use csdnsav6.lib.
Unicode: Implemented as Unicode and ANSI versions.

See Also

GetMailExchange


Copyright © 2008 Catalyst Development Corporation. All rights reserved.