Home All Groups Group Topic Archive Search About

Emailing CheckBoxList content

Author
8 Apr 2005 8:43 PM
Gamlyn
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 = "j**@schmoe.com"
           oMessage.From = "WebF***@company.com"
           oMessage.Subject = "Things selected"
           oMessage.Body = sBody1 & vbCrLf & sBody2

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

       End Sub
    </script>

Thank you!

Author
8 Apr 2005 9:02 PM
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

On Fri, 8 Apr 2005 13:43:02 -0700, Gamlyn
<Gam***@discussions.microsoft.com> wrote:

Show quoteHide quote
>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 = "j**@schmoe.com"
>           oMessage.From = "WebF***@company.com"
>           oMessage.Subject = "Things selected"
>           oMessage.Body = sBody1 & vbCrLf & sBody2
>
>            SmtpMail.Send(oMessage)
>            Response.Redirect("thankyou.aspx")
>
>       End Sub
>    </script>
>
>Thank you!
Author
8 Apr 2005 11:33 PM
Gamlyn
Thank you, it worked like a charm

Show quoteHide quote
"Marcie Jones" wrote:

> 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
>
> On Fri, 8 Apr 2005 13:43:02 -0700, Gamlyn
> <Gam***@discussions.microsoft.com> wrote:
>
> >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 = "j**@schmoe.com"
> >           oMessage.From = "WebF***@company.com"
> >           oMessage.Subject = "Things selected"
> >           oMessage.Body = sBody1 & vbCrLf & sBody2
> >
> >            SmtpMail.Send(oMessage)
> >            Response.Redirect("thankyou.aspx")
> >
> >       End Sub
> >    </script>
> >
> >Thank you!
>
>