Modifying an .aspx mailer which draws email address to mail to from a drop down list on a web form:
<p>I need to change the response to a mailer which is gets its instruction form a drop down selection box on the webpage. </p>

<p>The original code is working and appears fairly simple, but it emails the wrong department heads, because it isn't specific enough. </p>

<p>I'm not a coder, but I thought to have a stab at this.</p>

<p>This is the original code:</p>

<pre><code>       public partial class ContactUs : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {

        Calendar cal = new Calendar();
        string dat = cal.TodaysDate.Date.ToLongDateString();

            System.Web.Mail.MailMessage mm = new MailMessage();
            mm.From = "WBS Website&lt;info@wbs.ae&gt;";
            if (DrpDwnType.SelectedItem.Value == "G")
                mm.To = "david@wbs.ae";
            else
                mm.To = "robert@wbs.ae";

            mm.Cc = "wolfi@wbs.ae";
            mm.Bcc = "precise.customer@gmail.com";
            mm.Subject = "Online comments from WBS website visitor, " + TXTFname.Text;
            mm.Body = "&lt;div style='border:solid 2px RED; padding:25px 25px 25px 25px'&gt;&lt;br&gt;&lt;br&gt; &lt;strong&gt;Online comments from WBS website&lt;/strong&gt;&lt;br&gt; &lt;br&gt; ------------------------------------- &lt;br&gt; Date : " + dat + "&lt;br&gt; &lt;br&gt; First Name : " + TXTFname.Text + "&lt;br&gt;Last Name : " + TXTLastName.Text + "&lt;br&gt; Email Address : " + TXTEmail.Text + "&lt;br&gt; Contact No : " + TXTMob.Text + "&lt;br&gt; Enquiry Type : " + DrpDwnType.SelectedItem.Text + "&lt;br&gt; &lt;br&gt; &lt;br&gt; The visitor comment : &lt;br&gt; --------------------------------------- &lt;br&gt; " + TXTComment.Text + "&lt;/strong&gt;&lt;br&gt;&lt;br&gt;Further Information : " + RadioButtonList1.SelectedItem.Value.ToString() + "&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;/div&gt;";
            mm.BodyFormat = MailFormat.Html;
            SmtpMail.Send(mm);
            TXTFname.Text = "";
            TXTLastName.Text = "";
            TXTMob.Text = "";
            TXTComment.Text = "";
            TXTEmail.Text = "";
            TXTMess.Text = "Thank you for your interest in WBS!!! ";



    }
}
</code></pre>

<p>This is what I've come up with through my research: </p>

<pre><code>   public partial class ContactUs : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {

        Calendar cal = new Calendar();
        string dat = cal.TodaysDate.Date.ToLongDateString();

            System.Web.Mail.MailMessage mm = new MailMessage();
            mm.From = "WBS Website&lt;info@wbs.ae&gt;";

    if (DrpDwnType.SelectedItem.Value == "S")
        {
                mm.To = "gavin@wbs.ae";
        }
    else if (DrpDwnType.SelectedItem.Value == "R")
        {
                mm.To = "king@wbs.ae";
        }
    else
        {
                mm.To = "josh@wbs.ae";
        }       

            mm.Cc = "robert@wbs.ae;josh@wbs.ae";
            mm.Bcc = "wolfi@wbs.ae";
            mm.Subject = "Online comments from WBS website visitor, " + TXTFname.Text;
            mm.Body = "&lt;div style='border:solid 2px RED; padding:25px 25px 25px 25px'&gt;&lt;br&gt;&lt;br&gt; &lt;strong&gt;Online comments from WBS website&lt;/strong&gt;&lt;br&gt; &lt;br&gt; ------------------------------------- &lt;br&gt; Date : " + dat + "&lt;br&gt; &lt;br&gt; First Name : " + TXTFname.Text + "&lt;br&gt;Last Name : " + TXTLastName.Text + "&lt;br&gt; Email Address : " + TXTEmail.Text + "&lt;br&gt; Contact No : " + TXTMob.Text + "&lt;br&gt; Enquiry Type : " + DrpDwnType.SelectedItem.Text + "&lt;br&gt; &lt;br&gt; &lt;br&gt; The visitor comment : &lt;br&gt; --------------------------------------- &lt;br&gt; " + TXTComment.Text + "&lt;/strong&gt;&lt;br&gt;&lt;br&gt;Further Information : " + RadioButtonList1.SelectedItem.Value.ToString() + "&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;/div&gt;";
            mm.BodyFormat = MailFormat.Html;
            SmtpMail.Send(mm);
            TXTFname.Text = "";
            TXTLastName.Text = "";
            TXTMob.Text = "";
            TXTComment.Text = "";
            TXTEmail.Text = "";
            TXTMess.Text = "Thank you for your interest in WBS!!! ";


    }
}
</code></pre>

<p>At this point, this is a mental exercise for me. I may or not attempt to recompile the website without professional help. </p>

<p>** Edit: **<br>
<strong>I'm looking to find out if the code I've modified in the second portion will work, and if there is a better way to go about choosing the department that gets mailed based on the selection in the drop down list.</strong></p>

<p><strong>2nd Edit:</strong></p>

<p>Current:</p>

<pre><code>&lt;asp:DropDownList
     ID="DrpDwnType" runat="server" Width="260px" Font-Bold="True"&gt;
     &lt;asp:ListItem Value="0"&gt;-- select --&lt;/asp:ListItem&gt;
     &lt;asp:ListItem Value="G"&gt;General                  &lt;/asp:ListItem&gt;
     &lt;asp:ListItem Value="S"&gt;Service or Workshop&lt;/asp:ListItem&gt;
     &lt;asp:ListItem Value="R"&gt;Rental Bike&lt;/asp:ListItem&gt;
     &lt;asp:ListItem Value="C"&gt;Cycling in Dubai&lt;/asp:ListItem&gt;
&lt;/asp:DropDownList&gt;
</code></pre>

<p>New:</p>

<pre><code>&lt;asp:DropDownList
     ID="DrpDwnType" runat="server" Width="260px" Font-Bold="True"&gt;
     &lt;asp:ListItem Value="0"&gt;-- select --&lt;/asp:ListItem&gt;
     &lt;asp:ListItem Value="josh@wbs.ae"&gt;General&lt;/asp:ListItem&gt;
     &lt;asp:ListItem Value="gavin@wbs.ae"&gt;Service or Workshop&lt;/asp:ListItem&gt;
     &lt;asp:ListItem Value="king@wbs.ae"&gt;Rental Bike&lt;/asp:ListItem&gt;
     &lt;asp:ListItem Value="josh@wbs.ae"&gt;Cycling in Dubai&lt;/asp:ListItem&gt;
&lt;/asp:DropDownList&gt;
</code></pre>

<p>Then set the mailer to something like:</p>

<pre><code>public partial class ContactUs : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void Button1_Click(object sender, EventArgs e)
        {

            Calendar cal = new Calendar();
            string dat = cal.TodaysDate.Date.ToLongDateString();

                System.Web.Mail.MailMessage mm = new MailMessage();
                mm.From = "WBS Website&lt;info@wbs.ae&gt;";
                mm.To = DrpDwnType.SelectedValue;
                mm.Cc = "robert@wbs.ae;josh@wbs.ae";
                mm.Bcc = "wolfi@wbs.ae";
                mm.Subject = "Online comments from WBS website visitor, " + TXTFname.Text;
                mm.Body = "&lt;div style='border:solid 2px RED; padding:25px 25px 25px 25px'&gt;&lt;br&gt;&lt;br&gt; &lt;strong&gt;Online comments from WBS website&lt;/strong&gt;&lt;br&gt; &lt;br&gt; ------------------------------------- &lt;br&gt; Date : " + dat + "&lt;br&gt; &lt;br&gt; First Name : " + TXTFname.Text + "&lt;br&gt;Last Name : " + TXTLastName.Text + "&lt;br&gt; Email Address : " + TXTEmail.Text + "&lt;br&gt; Contact No : " + TXTMob.Text + "&lt;br&gt; Enquiry Type : " + DrpDwnType.SelectedItem.Text + "&lt;br&gt; &lt;br&gt; &lt;br&gt; The visitor comment : &lt;br&gt; --------------------------------------- &lt;br&gt; " + TXTComment.Text + "&lt;/strong&gt;&lt;br&gt;&lt;br&gt;Further Information : " + RadioButtonList1.SelectedItem.Value.ToString() + "&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;/div&gt;";
                mm.BodyFormat = MailFormat.Html;
                SmtpMail.Send(mm);
                TXTFname.Text = "";
                TXTLastName.Text = "";
                TXTMob.Text = "";
                TXTComment.Text = "";
                TXTEmail.Text = "";
                TXTMess.Text = "Thank you for your interest in WBS!!! ";


        }
    }
</code></pre>

<p>I hope this kind of question is not too much bother.</p>
