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

时间:2018-12-17 19:20:12

标签: forms email checkbox input

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

<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>

1 个答案:

答案 0 :(得分:0)

我终于可以从此页面找到解决方案: https://forums.asp.net/t/1825115.aspx?How+do+I+get+Checkbox+values+and+email+them+

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