Chilkat Email Components Home

Verify SMTP Login and Connection Methods

Back

The VerifySmtpLogin and VerifySmtpConnection methods are intended to be used as a diagnostic to help in error reporting. The code below explains...
    ' This is very inefficient.  Each time an email is sent, it causes
    ' three connections to the SMTP server to occur: one for the VerifySmtpConnection,
    ' one for the VerifySmtpLogin, and one for the SendEmail.
    If .VerifySmtpConnection And .VerifySmtpLogin Then
    	.SendEmail(Email)
    End If

    ' This is more efficient.  The intent of the VerifySmtpConnection and VerifySmtpLogin
    ' methods are to diagnose the SMTP failure when a .SendEmail fails (or when other
    ' SMTP related methods fail).
    If Not .SendEmail(Email) Then
        ' If the send fails, determine if it was a connectivity issue (such as 
        ' you may get with a firewall blocking port 25, a login issue, or something else.
        If Not .VerifySmtpConnection Then
            MessageBox.Show("Failed to establish TCP/IP Connection to SMTP Server")
        ElseIf Not .VerifySmtpLogin Then
            MessageBox.Show("SMTP Login is Incorrect")
        Else
            MessageBox.Show(.LastErrorText)
        End If
    End If