MailExchange Property  
 

Return the name of the mail exchange host for the specified domain.

Syntax

object.MailExchange(Index)

Remarks

The MailExchange property array returns the host name of the systems designated as the mail exchangers for the current domain. The mail exchange hosts are returned sorted in priority order, with the higher priority mail servers being listed first. The property array is zero based, which means that the first index value is zero. The HostName property must be set to the domain name that you want to obtain the mail exchange records for.

This property array is commonly used to determine which system is responsible for forwarding mail within a domain. For example, if a mail message is addressed to the user someone@example.com, you can determine the name of the server or servers responsible for accepting mail for that user by setting the value of the HostName property to example.com and then checking the MailExchange property array. Note that it is possible that a domain will not have any mail exchange (MX) records, in which case you should attempt to to connect directly to a mail server running on the host specified in the domain name portion of the address.

Data Type

String

Example

The following example places the all of the mail exchanges for a specific host into a listbox:

Dim nIndex As Integer

List1.Clear
DnsClient1.HostName = Trim(Text1.Text)

For nIndex = 0 To DnsClient1.MailExchanges - 1
     List1.AddItem DnsClient1.MailExchange(nIndex)
     nIndex = nIndex + 1
Loop

See Also

HostName Property, HostAddress Property, NameServer Property, MailExchanges Property