Emailing CheckBoxList content

G

Guest

Can anyone please show me what the VB would look like to get CheckBoxList
form results into a oMessage.Body for sending in email?

This is an example of my CheckBoxList:
<asp:CheckBoxList ID="ckbThings" runat="server">
<asp:ListItem Value="Thing 1">Thing 1</asp:ListItem>
<asp:ListItem Value="Thing 2">Thing 2</asp:ListItem>
<asp:ListItem Value="Thing 3">Thing 3</asp:ListItem>
</asp:CheckBoxList>

I have the following code already (where ????????? is what I can't figure
out). I suspect I need another Dim, but how does it all come together?:

<script language="vb" runat="server">
Sub btnSendEmail_OnClick(sender As Object, e As EventArgs)

Dim sBody1, sBody2
sBody1 = "My name is: " & txtName.Text
sBody2 = "I chose these things: " ?????????????

Dim oMessage As New MailMessage
oMessage.To = "(e-mail address removed)"
oMessage.From = "(e-mail address removed)"
oMessage.Subject = "Things selected"
oMessage.Body = sBody1 & vbCrLf & sBody2

SmtpMail.Send(oMessage)
Response.Redirect("thankyou.aspx")

End Sub
</script>

Thank you!
 
M

Marcie Jones

Something like this:
sBody2 = "I chose these things: "
Dim item As ListItem
For Each item in ckbThings.Items
If item.Selected Then sBody2 = sBody2 & item.Text & ", "
Next
sBody2 = sBody2.SubString(0, sBody2.Length() -2)

Marcie
 
G

Guest

Thank you, it worked like a charm

Marcie Jones said:
Something like this:
sBody2 = "I chose these things: "
Dim item As ListItem
For Each item in ckbThings.Items
If item.Selected Then sBody2 = sBody2 & item.Text & ", "
Next
sBody2 = sBody2.SubString(0, sBody2.Length() -2)

Marcie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top