private void SendMessage(EmailMessage message, string username, string password, string host, int port, bool enableSsl)
        {
            var from = new MailAddress(message.From, message.DisplayNameFrom);
            var to = new MailAddress(message.To);

            var mm = new MailMessage(from, to)
            {
                Subject = message.Subject,
                Body = message.Message,
                BodyEncoding = System.Text.Encoding.UTF8,
                IsBodyHtml = true
            };

            var credentials = new NetworkCredential(username, password);
            var sc = new SmtpClient(host, port)
            {
                EnableSsl = enableSsl,
                Credentials = credentials
            };

            sc.Send(mm);
        }
        public JsonResult SendOrder(Order model)
        {
            var email = new EmailMessage
                {
                    DisplayNameFrom = "Заказ тренинга",
                    From = "*****@*****.**",
                    To = "*****@*****.**",
                    Subject = string.Format("Заявка на треннинг \"{0}\"", model.Training),
                    Message = string.Format("Заявка на получение: <b>{0}</b><br/>" +
                                            "Имя: <b>{1}</b><br/>" +
                                            "Телефон: <b>{2}</b><br/>" +
                                            "Email: <b>{3}</b><br/>" +
                                            "Комментарий: <b>{4}</b>",
                                            model.Training,
                                            model.Name,
                                            model.Phone,
                                            model.Email,
                                            model.Comment)
                };

            SendMessage(email, "*****@*****.**", "123456aaa111", "smtp.yandex.ru", 587, true);

            return Json(true);
        }