如何在电子邮件正文消息中显示电子邮件表单的复选框



我正在尝试创建一个联系我们表单。我有一些文本输入字段、下拉菜单和复选框。在进行故障排除时,我可以从文本框输入和下拉菜单中提取文本。不幸的是,当我试图从添加到电子邮件正文消息的复选框中获取值时,我的代码中断了。提交表单时,如何在电子邮件正文中包含"已勾选"值的框?下面是一个示例代码。谢谢你的帮助。

<head>
msg.Subject = "Test Form";
msg.Body = "n Name: " + txtname.Text + Environment.NewLine + "n Color: " + color.Text + Environment.NewLine + "n Shape " + shape.Value;
</head>    
<body>
<asp:TextBox AlternateText="Name Field" id="txtname" runat="server" 
MaxLength="32" placeholder="Name" alt="Name*" type="text" > 
</asp:TextBox>
<asp:DropDownList id="color" runat="server" AlternateText="Color Field" 
placeholder="Color" alt="Color Field" type="text" >
<asp:ListItem Text="Blue" Value="blue" />
<asp:ListItem Text="Red" Value="red" />
<asp:ListItem Text="White" Value="white" />
</asp:DropDownList>
<fieldset>        
<label for="circle">Circle<input type="checkbox" name="shape" id="circle">
</label>
<label for="square">Square<input type="checkbox" name="shape" id="square">
</label>
<label for="triangle">Triangle<input type="checkbox" name="shape" id="triangle">
</label>
</fieldset>
</body>

我终于从这个页面找到了一个解决方案:https://forums.asp.net/t/1825115.aspx?How+do+I+get+复选框+值+和+电子邮件+他们+

<head>
msg.Subject = "Test Form";
msg.Body = "n Name: " + txtname.Text + Environment.NewLine + "n Color: " + color.Text + Environment.NewLine + "n Shape " + Request["shape"];
</head>  

最新更新