I have a form that sends the results to my email address and works fine. However I want to send it to a different email address based on user selection.
On the form there is a list of radio buttons:
<p>My message is for:</p>
<asp:RadioButton ID="UserA" GroupName="Recipient" class="formfield" runat="server" />User A<br />
<asp:RadioButton ID="UserB" GroupName="Recipient" class="formfield" runat="server" />User B<br />
In the code behind I have the following:
SmtpClient sc = new SmtpClient();
StringBuilder sb = new StringBuilder();
MailMessage msg = null;
sb.Append("Email from: " + txtName.Text + "\n");
sb.Append("Email: " + txtEmail.Text + "\n");
sb.Append("Tel: " + txtPhone.Text + "\n");
sb.Append("Question / Comments: " + txtQuestion.Text + "\n");
msg = new MailMessage(txtEmail.Text, "email@example.com", txtSubject.Text, sb.ToString());
pnlForm.Visible = false;
pnlConfirm.Visible = true;
At the moment the email goes to "firstname.lastname@example.org". I presume I need to change that to the value from the RadioButton but also need to relate the value (UserA or UserB) to email@example.com or firstname.lastname@example.org.
I'm going around in circles at the moment on what should be reasonably simple.