GetEmailServer Method

Retrieve recipient's SMTP server address via DNS lookup

[Syntax]
C++: HRESULT GetEmailServer( BSTR EmailAddr, BSTR DNSAddr, BSTR* pVal )
Visual Basic: GetEmailServer( EmailAddr As String, DNSAddr As String ) As String
C#: string GetEmailServer( string EmailAddr, string DNSAddr )

Parameter:

EmailAddr

Email address for SMTP server lookup.

DNSAddr

Valid DNS server address. If this value is "", ANSMTP uses the default DNS address of your computer. It is recommended to specify a DNS server address on windows 95.

Return Values

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

Remarks

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.

In ANSMTP 3.5 or later, we don't recommend using this method directly any more. If you do not put any value to ServerAddr property of ANSMTP, ANSMTP sends email via DNS lookup automatically.

Usage Example:

[Visual Basic]
Private Sub SendEmailByDns()
  Dim oSmtp As New AOSMTPLib.Mail
  Dim Server As String 
  
  'Retrieve SMTP server address
  Server = oSmtp.GetEmailServer( "dennis@email.com", "" )
  oSmtp.ServerAddr = Server
  oSmtp.AddRecipient "Dennis", "Dennis@email.com", 0 
  ...
End Sub

See Also

ServerAddr Property
ImportMailEx Method


2001-2007 © Copyright AdminSystem Software Limited. All rights reserved.