GetEmailServer Method

Retrieve recipient's SMTP server address via DNS lookup

Visual C++: HRESULT GetEmailServer(BSTR EmailAddr, BSTR* pVal)
Visual Basic: GetEmailServer(EmailAddr As String) As String


Email address for SMTP server lookup.

Return Value

If this method succeeds, the return value is the SMTP server address of specified email address; otherwise the return value is "".


With this method, your application is able to send email without specified SMTP server. And you needn't to do ESMTP authentication.
For different domain's email address, you need to retrieve their SMTP server address separately.
However, we don't recommend using this method directly any more. If you do not put any value to ServerAddr property of Mail object, Mail object sends email via DNS lookup automatically.


[VB6, VBA - Query MX Record and Send Email]
Private Sub SendEmailByDns()
  Dim oSmtp As New EASendMailObjLib.Mail
  oSmtp.LicenseCode = "TryIt"
  Dim Server As String 
  'Retrieve SMTP server address
  Server = oSmtp.GetEmailServer("" )
  oSmtp.ServerAddr = Server
  oSmtp.AddRecipient "Dennis", "", 0 
End Sub

See Also

Send Email without SMTP server(DNS lookup)
ServerAddr Property
ImportMailEx Method