我在ASP.NET C#中创建一个表单,以便可以填写并通过电子邮件发送给多个收件人。表单的一部分是一个复选框部分,其中包含多个选项。我只能选择第一个选项通过电子邮件发回给收件人,所以如果用户选择两个或多个复选框,它只会通过电子邮件发送第一个选项。以下是我的代码单ASP.NET复选框控件
SmtpClient smtpClient = new SmtpClient();
MailMessage message = new MailMessage();
MailAddress From = new MailAddress(mailTextBox.Text);
message.To.Add(new MailAddress("[email protected]"));
message.Subject = (companyTextBox.Text);
message.IsBodyHtml = true;
message.Body = "<html><head></head><body>" +
"<p></p>" +
"<p>Business Type: " + typeDropDownList.Text + "</p>" +
"<p>Company: " + companyTextBox.Text + "</p>" +
"<p>Name: " + nameTextBox.Text + "</p>" +
"<p>Address: " + addressTextBox.Text + "</p>" +
"<p>City: " + cityTextBox.Text + "</p>" +
"<p>State: " + stateDropDownList.Text + "</p>" +
"<p>Zip Code: " + zipcodeTextBox.Text + "</p>" +
"<p>Phone Number: " + phoneTextBox.Text + "</p>" +
"<p>Email: " + mailTextBox.Text + "</p>" +
"<p>Number Of Locations: " + locationsDropDownList.Text + "</p>" +
**// This is my problem area //**
"<p>Interested In: " + interestedCheckBoxList.Text + "</p>" +
"<p>Interested In: " + interestedCheckBoxList.Text + "</p>" +
"<p>Interested In: " + interestedCheckBoxList.Text + "</p>" +
**// This is my problem area //**
"<p>Message: " + messageTextBox.Text + "</p>" +
"</body></html>";
smtpClient.Send(message);
Response.Redirect("http://www.domain.com");
在此先感谢您。
吉姆
你正在采取相同的3行代码并复制它。 – Cyberdrew 2011-03-22 18:38:56
我也推荐使用StringBuilder。 – Cyberdrew 2011-03-22 18:39:43
此外,CheckBox控件和asp.net中的CheckBoxList控件有所不同。小心不要让他们困惑。 – 2011-03-22 18:41:07