views:

593

answers:

1

Hello,

I have a asp:Wizard control on a site running Framework 3.5. I acquired the settings from the web host and have entered them into the Web Configuration Utility. Here's the code behind file:

Protected Sub Wizard1_FinishButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles Wizard1.FinishButtonClick
    Dim mySMTPClient As New SmtpClient()
    Dim sb As New StringBuilder
    Dim myMail As New MailMessage("[email protected]", "[email protected]")
    Dim myFrom As New MailAddress("[email protected]")
    Dim myTo As New MailAddress("[email protected]")
    myMail.BodyEncoding = System.Text.Encoding.UTF8
    myMail.IsBodyHtml = False
    myMail.To.Add(myTo)
    myMail.Subject = "Request for Information"
    sb.Append("Contact Name: ")
    sb.Append(txtcontactname.Text)
    sb.Append("<br/>Phone Number: ")
    sb.Append(txtcontactphone.Text)
    sb.Append("<br/>Employer Name: ")
    sb.Append(txtemployername.Text)
    sb.Append("<br/>City: ")
    sb.Append(txtcity.Text)
    sb.Append("<br/>State: ")
    sb.Append(cmbstate.Text)
    sb.Append("<br/>Zip: ")
    sb.Append(txtzip.Text)
    sb.Append("<br/>Other Location: ")
    sb.Append(txtotherloc.Text)
    sb.Append("<br/>Nature of Business: ")
    sb.Append(txtbusnat.Text)
    sb.Append("<br/>Eligible Employees: ")
    sb.Append(txteligemps.Text)
    sb.Append("<br/>Average Employee Turnover Per Year: ")
    sb.Append(txtempturnover.Text)
    sb.Append("<br/>Broker Name: ")
    sb.Append(txtbrokername.Text)
    sb.Append("<br/>Broker Email: ")
    sb.Append(txtbrokeremail.Text)
    sb.Append("<br/>Proposed Effective Date: ")
    sb.Append(txteffdate.SelectedDate)
    sb.Append("<br/>Limited Benefit Medical Plans: ")
    For Each item As ListItem In chkmedplans.Items
        If (item.Selected) Then
            sb.Append(item.Text)
            sb.Append(" ")
        End If
    Next
    sb.Append("<br/>Voluntary Products/Services: ")
    For Each item As ListItem In chkvolserv.Items
        If (item.Selected) Then
            sb.Append(item.Text)
            sb.Append(" ")
        End If
    Next
    sb.Append("<br/>Employer Paid Products/Services: ")
    For Each item As ListItem In chkempserv.Items
        If (item.Selected) Then
            sb.Append(item.Text)
            sb.Append(" ")
        End If
    Next
    sb.Append("<br/>Preferred Benefit Enrollment Program(s): ")
    For Each item As ListItem In chkenrolprog.Items
        If (item.Selected) Then
            sb.Append(item.Text)
            sb.Append(" ")
        End If
    Next
    sb.Append("<br/>Comments: ")
    sb.Append(txtcomments.Text)
    myMail.Body = sb.ToString()
    Try
        mySMTPClient.Send(myMail)
    Catch ex As Exception
        Dim ex2 As Exception = ex
        Dim errorMessage As String = String.Empty
        While Not (ex2 Is Nothing)
            errorMessage += ex2.ToString()
            ex2 = ex2.InnerException
        End While
        Response.Write(errorMessage)
    End Try
End Sub

End Class

The code complies with no error. When loaded onto the shared hosting account, the page loads and the code allows the user to enter information into the wizard. However, the Finish button does not fire the final step. Here's the code for the final wizard step:

<asp:WizardStep ID="WizardStep4" runat="server" StepType="Complete" Title="Complete">
        Thank you for your inquiry.  A member of our staff will contact you regarding your request.</asp:WizardStep>

I cannot determine what is cuasing this issue. Can someone direct me as to possible causes?

Thanks, Sid

+1  A: 

Have you set breakpoints within the code to see if the code to send mail is actually being reached? For example, I would suggest you set breakpoints at least at the following:

To verify the FinishButtonClick event is firing.

Dim mySMTPClient As New SmtpClient()

To verify the Sendmail code is being hit.

mySMTPClient.Send(myMail)

To see if any exception is occurring.

Dim ex2 As Exception = ex

Also, there are at least a couple of other things to look out for.

  1. The SMTP server may not be configured or properly configured.

  2. Even if the SMTP Server is properly configured, you want to make sure your firewall (or your ISPs) is not blocking the sending of SMTP mail.

Anthony Gatlin
It turned out I received incorrect SMTP settings from web host's support technician. Thanks for your help!!!
SidC