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, "firstname.lastname@example.org", txtSubject.Text, sb.ToString());
pnlForm.Visible = false;
pnlConfirm.Visible = true;
At the moment the email goes to "email@example.com". I presume I need to change that to the value from the RadioButton but also need to relate the value (UserA or UserB) to firstname.lastname@example.org or email@example.com.
I'm going around in circles at the moment on what should be reasonably simple.