public ActionResult Application(CareerApplication model)
        {
            ViewBag.States = GetStates();

            if (ModelState.IsValid)
            {
                // Send the content to the database
                // Mark the career application as unread
                model.MessageStatusId = 1;
                db.CareerApplication.Add(model);
                db.SaveChanges();
                // Send an email to the [email protected]
                string emailAddress = System.Configuration.ConfigurationManager.AppSettings["CareerEmail"].ToString();
                string link         = System.Configuration.ConfigurationManager.AppSettings["website"].ToString() + "/Careers/ApplicationDetails/";
                if ((emailAddress == null) || (emailAddress == ""))
                {
                    emailAddress = "*****@*****.**";
                }
                var emailSent = SendEmail(emailAddress, link + model.CareerApplicationId, model);
                // Redirect the user to the confirmation page
                if (emailSent)
                {
                    return(RedirectToAction("Done"));
                }
                else
                {
                    return(View("Error"));
                }
            }
            return(View(model));
        }
        private bool SendEmail(string sendTo, string link, CareerApplication model)
        {
            var smtpServer = "mail.connectuspro.com";
            //var yourEmail = "*****@*****.**";
            var yourEmail    = "*****@*****.**";
            var yourPassword = "******";

            //var TechSettings = "";
            //foreach (var item in Request.ServerVariables.AllKeys)
            //{
            //    TechSettings = String.Format("{0}{1}: {2}<br />", TechSettings, item, Request.ServerVariables[item]);
            //}
            var           subject = "A career application identified by " + model.CareerApplicationId + " was created in 1800plumber.com at " + DateTime.Now;
            StringBuilder strBody = new StringBuilder();

            strBody.Append(String.Format("<font face=\"Arial\">Career application details: {0}<br /><br />", DateTime.Now));
            strBody.Append(String.Format("From http://{0}<br />", Request.ServerVariables["HTTP_HOST"]));
            strBody.Append(String.Format("IP Address : {0}<br />", Request.UserHostAddress));
            strBody.Append(String.Format("First and Last name : {0}<br />", model.FirstLastName));
            strBody.Append(String.Format("Phone : {0}<br />", model.Phone));
            strBody.Append(String.Format("Email : {0}<br />", model.Email));
            strBody.Append(String.Format("Subject : {0}<br />", subject));

            strBody.Append(String.Format("<br /><br /><a href=\"{0}\" target=\"_blank\">Click here to view the application on line</a>", link));

            //strBody.Append(TechSettings + "<br />");
            strBody.Append("</font>");

            using (var mailMessage =
                       new MailMessage(new MailAddress(yourEmail),
                                       new MailAddress(sendTo))
            {
                Subject = subject,
                IsBodyHtml = true,
                Body = strBody.ToString()
            })
            {
                System.Net.NetworkCredential networkCredentials = new System.Net.NetworkCredential(yourEmail, yourPassword);
                using (SmtpClient smtpClient = new SmtpClient()
                {
                    EnableSsl = false,
                    UseDefaultCredentials = false,
                    Credentials = networkCredentials,
                    Host = smtpServer,
                    Port = 25
                })
                {
                    try
                    {
                        smtpClient.Send(mailMessage);
                    }
                    catch (Exception ex)
                    {
                        _message = ex.Message;
                        return(false);
                    }
                }
            }

            return(true);
        }