Mail Form Drop down

I have a drop down selection for the person to select the country and the recipient to receive it but not sure how to put in the mailMessage.Body = and I tried "<b>Country : </b>" + txtddlCountries.Text + "<br/>" but that does send it. Not sure what to use.

Protected Sub Button1_Click(sender As Object, e As EventArgs)
        Try
            Dim mailMessage As New MailMessage()
            mailMessage.From = New MailAddress("csosa777@gmail.com")
            mailMessage.[To].Add("csosa@iogproducts.com")
            mailMessage.Subject = txtSubject.Text

            mailMessage.Body = "<b>Sender Name : </b>" + txtname.Text + "<br/>" + "<b>Sender Email : </b>" + txtEmail.Text + "<br/>" + "<b>Phone : </b>" + txtPhone.Text + "<br/>" + "<b>Subject : </b>" + txtSubject.Text + "<br/>" + "<b>Company : </b>" + txtCompany.Text + "<br/>" + "<b>Items Being Shipped : </b>" + txtItembeingshipped.Text + "<br/>" + "<b>How fragile is the shipment? : </b>" + txtHowfragileistheshipment.Text + "<br/>" + "<b>What are the dimensions of the shipment? : </b>" + txtWhatarethedimensionsoftheshipment.Text + "<br/>" + "<b>How much does shipment weigh? : </b>" + txtHowmuchdoesshipmentweigh.Text + "<br/>" + "<b>Comments : </b>" + txtComments.Text
            mailMessage.IsBodyHtml = True

            Dim smtpClient As New SmtpClient("relay-hosting.secureserver.net", 25)
            smtpClient.Send(mailMessage)

            Label1.Text = "Thanks for contacting us"
            Label1.ForeColor = System.Drawing.Color.Blue

            txtname.Enabled = False
            txtEmail.Enabled = False
            txtComments.Enabled = False
            txtSubject.Enabled = False
            Button1.Enabled = False
        Catch generatedExceptionName As Exception
            ' Log - Event Viewer or table 
            Label1.ForeColor = System.Drawing.Color.Blue
            Label1.ForeColor = System.Drawing.Color.Red
            Label1.Text = "There is an unknown problem. Please try later"
        End Try
    End Sub

.SelectedValue instead of .Text

I still get this…Compiler Error Message: BC30451: Name 'txtddlCountries' is not declared.

Without seeing the HTML markup, I’d guess that it should be ddlCountries instead of txtddlCountries

<asp:DropDownList ID="ddlCountries" runat="server" Height="23px" OnSelectedIndexChanged="ddlCountries_SelectedIndexChanged"

That confirms it. You have txtddlCountries in your code but your HTML clearly indicates it is ddlCountries.

Thanks.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.