سلام این هم کد
ابتدا کد فرم .
در اینجا یک دیتا لیست محتویات جدول را نمایش میدهد! برای هر ایتم یک چک باکس گذاشته ام .
سپس نام و ایمیل و متنی از کاربر گرفته میشود! و در نهایت با زدن دکمه ارسال ایمیل میشود
در حال حاضر فقط نام و ایمیل و متن کاربر ارسال میشود
میخواهم کاری کنم که هر آیتمی که تیک خورده بود هم اسمش مثلا به متن اضافه شود
<%@ Page Title="فروش آنلاین" Language="VB" MasterPageFile="~/MFarsi.master" AutoEventWireup="true" CodeFile="shopform1.aspx.vb" Inherits="Default2" %>
<asp:Content ID="Content3" ContentPlaceHolderID="head" Runat="Server">
<style type="text/css">
.style10
{
height: 544px;
}
</style>
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<table cellpadding="0" cellspacing="0">
<tr>
<td width="780" valign="top" class="style10" align="center">
<div align="center">
<asp:SqlDataSource ID="ds" runat="server" ConnectionString="<%$ ConnectionStrings:dbsConnectionString %>"
SelectCommand="SELECT * FROM [products] "></asp:SqlDataSource>
</div>
<%-- Open the DataList control and set it for two columns, to be filled in horizontal order. --%>
<ASP:DataList id="DataList1" RepeatColumns="3" DataSourceID="ds" RepeatDirection= "Horizontal" runat="server">
<%-- Create a DataList control template named "ItemTemplate". --%>
<ItemTemplate>
<div style="padding:15,15,15,15;font-size:10pt;font-family:Tahoma;color:White; margin:0 auto; direction:rtl; border:dotted 1px;">
<img src="<%# DataBinder.Eval(Container.DataItem, "img")%> " />
<br>
<%# DataBinder.Eval(Container.DataItem, "name")%><br>
<b>قیمت کارت سخا: </b>
<%# DataBinder.Eval(Container.DataItem, "price_sakha") %><br>
<b>قیمت نقد: </b>
<%# DataBinder.Eval(Container.DataItem,"price_naghd", "{0:c}") %><br>
انتخاب: <asp:CheckBox ID="chkbox" runat="server" /><br />
<p>
</div>
</ItemTemplate>
</ASP:DataList>
</td>
</tr>
</table>
<table border="0" width="60%" align="right" cellpadding="2" cellspacing="2" style="direction: rtl;
text-align: right; font-family: Tahoma; font-size: 11px; line-height: 22px;">
<tr>
<td >
<font color="White"> نام و نام خانوادگی </font>
</td>
<td>
<asp:TextBox ID="txtname" runat="server" Width="200px" CssClass="text"
Font-Size="11px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="TXTName" ErrorMessage="*">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td >
<font color="White"> پست الکترونیک </font>
</td>
<td>
<asp:TextBox ID="txtemail" runat="server" Width="200px" CssClass="text"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="TXTEmail" ErrorMessage="*">*</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="TXTEmail" ErrorMessage="Email Format Fail"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">Email Format Fail</asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td valign="middle" >
<font color="White"> متن </font>
</td>
<td valign="middle">
<asp:TextBox ID="txtcomment" runat="server" Font-Names="tahoma"
Font-Size="11px" Rows="8"
TextMode="MultiLine" Width="338px"></asp:TextBox>
</td>
</tr>
<tr>
<td >
</td>
<td align="left">
<asp:Button ID="Button1" runat="server" Text="ارسال" OnClick="Button1_Click" Style="padding: 3px;
width: 50px; cursor: pointer; height: 25px; border: 1px solid silver; text-align: center;
font-family: Tahoma; font-size: 11px;" /> & nbsp;
<div style="float: right;">
<asp:Label ID="LBLMesage" runat="server" ForeColor="White"></asp:Label>
</div>
</td>
</tr>
</table>
</asp:Content>
این قسمت کد ارسال ایمیل هست!
Imports System.Net.Mail
Imports System.Net
Imports System.Data
Imports System.Data.SqlClient
Partial Public Class Default2
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim mail As New MailMessage()
Dim a As String
Dim b As String
'set the addresses
'mail.To.Add("info@slslsl.com")
mail.To.Add("hatami@slslsl.com")
mail.From = New MailAddress(txtemail.Text)
'set the content
mail.Subject = "خرید اینترنتی"
mail.Body = "name : " & txtname.Text & "<br />subject : خرید اینترنتی <br />" & "email : " & txtemail.Text & "<br />"
mail.Body = mail.Body & "<br /> Text: " & txtcomment.Text
mail.IsBodyHtml = True
'send the message
Dim smtp As New SmtpClient("mail.slslsl.com")
'to authenticate we set the username and password properites on the SmtpClient
smtp.Credentials = New NetworkCredential("form@slslsl.com", "password")
' smtp.Port = 587
Try
smtp.Send(mail)
LBLMesage.Text = "پیام شما با موفقیت ارسال شد"
txt.Text = ""
txtcomment.Text = ""
txtemail.Text = ""
txtname.Text = ""
Catch ex As Exception
LBLMesage.Text = ex.Message()
End Try
End Sub
End Class