473,385 Members | 1,944 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Emailing CheckBoxList content

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 = "jo*@schmoe.com"
oMessage.From = "We*****@company.com"
oMessage.Subject = "Things selected"
oMessage.Body = sBody1 & vbCrLf & sBody2

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

End Sub
</script>

Thank you!
Nov 21 '05 #1
2 1037
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
<Ga****@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 = "jo*@schmoe.com"
oMessage.From = "We*****@company.com"
oMessage.Subject = "Things selected"
oMessage.Body = sBody1 & vbCrLf & sBody2

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

End Sub
</script>

Thank you!


Nov 21 '05 #2
Thank you, it worked like a charm

"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
<Ga****@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 = "jo*@schmoe.com"
oMessage.From = "We*****@company.com"
oMessage.Subject = "Things selected"
oMessage.Body = sBody1 & vbCrLf & sBody2

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

End Sub
</script>

Thank you!


Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Mike Moore | last post by:
What is the best way to launch outlook from an asp.net web page? Can you do this using MAPI or is there a control that you can purchase? We are unable to use SMTP. We use MS Exhange and MAPI...
3
by: Sully | last post by:
Hi, I am having a small problem generating an e-mail via an online form. I am creating an e-mail using the MailMessage command and I know that you have to do something special to render the values...
1
by: prk72 | last post by:
I'm not sure if this should be posted in the VB forum, the .NET forum or here. I know how to create a CheckBoxList, add items and have them checked or unchecked but my problem is I'm pulling the...
0
by: =?Utf-8?B?S04=?= | last post by:
I am getting the following exception in a page while using the Checkboxlist control. This happens on postback. startIndex cannot be larger than length of string. Parameter name: startIndex...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.