Hi all, I'm interviewing for a new job and I will have to interact with C# in my job but only very limited capacity. They gave me this problem to solve and I think I found a way to solve it but I'd love you all's feedback if I said the right thing. I have to go in and explain it on Tues.
Did I do it correctly??
Thank you!!
This is what they asked:
public static void SendEmail(string emailFrom, string emailTo, string subject, string msgBody)
protected void btnSubmit_Click(object sender, EventArgs e)
{
string msgBody = string.Empty;
string subject = string.Empty;
msgBody = "<h1>Contact Public Assistance</h1><p>This email was received from a user of the County Website.</p>"
+ "<dl>"
+ "<dt>Name:</dt>"
+ "<dd>" + txtName.Text + "</dd>"
+ "<dt>Email:</dt>"
+ "<dd>" + txtEmail.Text + "</dd>"
+ "<dt>Questions / Comments:</dt>"
+ "<dd>" + txtQuestions.Text.Replace(Environment.NewLine, "<br />") + "</dd>"
+ "</dl>";
subject = "Web Contact: Public Assistance Question";
SendEmail(ConfigurationManager.AppSettings["emailNoReply"], subject, "<p>There are new comments from a https://www.county.org/publicassistance user.</p>" + msgBody);
subject = "Random County: Public Assistance Question";
SendEmail(ConfigurationManager.AppSettings["emailNoReply"], txtEmail.Text, subject, "<p>Your question/comment has been received and we will reply as soon as possible.</p>" + msgBody);
}
What I have tried:
protected void btnSubmit_Click(object sender, EventArgs e)
{
string msgBody = string.Empty;
string subject = string.Empty;
msgBody = "<h1>Contact Public Assistance</h1><p>This email was received from a user of the County Website.</p>"
+ "<dl>"
+ "<dt>Name:</dt>"
+ "<dd>" + txtName.Text + "</dd>"
+ "<dt>Email:</dt>"
+ "<dd>" + txtEmail.Text + "</dd>"
+ "<dt>Questions / Comments:</dt>"
+ "<dd>" + txtQuestions.Text.Replace(Environment.NewLine, "<br />") + "</dd>"
+ "</dl>";
subject = "Web Contact: Public Assistance Question";
SendEmail(ConfigurationManager.AppSettings["emailNoReply"], "pamanager@randomgov.org", subject, "<p>There are new comments from a https://www.county.org/publicassistance user.</p>" + msgBody);
subject = "Random County: Public Assistance Question";
SendEmail(ConfigurationManager.AppSettings["emailNoReply"], txtEmail.Text, subject, "<p>Your question/comment has been received and we will reply as soon as possible.</p>" + msgBody);
}