Test if an email address is valid.
[Syntax] C++: HRESULT TestEmailAddr( BSTR EmailAddr, BSTR DNS, long* pVal ) Visual Basic: TestEmailAddr( EmailAddr As String, DNS As String ) As Long C#: long TestEmailAddr( string EmailAddr, string DNS )
EmailAddr
The email address to test.
DNS
Valid DNS server address. If this value is "", ANSMTP uses the default DNS address of your machine.
Return Values
If this method succeeds, the return value is zero; otherwise the return value is non-zero.
Remarks
With this method, your application can test if an email address is valid. Warning: it is not 100% correct.
How does it work? Firstly, ANSMTP performs a DNS MX record query. If it retrieve the recipient's local SMTP server successfully, ANSMTP will try to connect to this server. ANSMTP then perform "RCPT TO" command to test if this SMTP server accept this email address.
Before invoking this method, please make sure your computer is connected to the Internet.
Usage Example:
[Visual Basic]
Private Sub TestEmailAddress()
Dim oSMTP As New AOSMTPLib.Mail
If oSMTP.TestEmailAddr( "dennis@msn.com", "" ) = 0 Then
MsgBox "valid email address"
Else
MsgBox "it may be an invalid email address"
End If
End Sub
2001-2007 © Copyright AdminSystem Software Limited. All rights reserved.