Beispiel #1
0
        public ActionResult ContactUs(QuestionViewModel model)
        {
            if(ModelState.IsValid)
            {
                try
                {
                    var Smtp = new SmtpClient("smtp.mail.ru", 25);
                    Smtp.Credentials = new NetworkCredential("", ""); //create new mail.ru account and enter crenditails here
                    Smtp.EnableSsl = true;

                    //Message formating
                    System.Net.Mail.MailMessage Message = new System.Net.Mail.MailMessage();
                    //From 
                    Message.From = new MailAddress("");//email from should be equal to the created one
                    //To
                    Message.To.Add(new MailAddress(""));//mail address where message will be sent
                    Message.Subject = "Need support: " + model.Subject;
                    string message = "From: " + model.Email + " ";
                    message = message + "\n";

                    message = message + model.Question;

                    Message.Body = message;

                    Smtp.Send(Message);//sending

                    ViewBag.successMessage = "Thank you for your question! The support staff will connect with you soon.";
                }
                catch (Exception e)
                {
                    ViewBag.successMessage = "An error has occured. Please try again later";
                }
            }
            return View(model);
        }
Beispiel #2
0
 public ActionResult ContactUs()
 {
     var model = new QuestionViewModel();
     return View(model);
 }