public async Task <ViewResult> Edit(SxVMSiteQuestion model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var mm = new SxAppMailManager();

            var sb = new StringBuilder();

            sb.AppendLine(model.Email);
            sb.AppendLine(model.UserName);
            sb.AppendLine(model.Text);

            var result = await mm.SendMail(sb.ToString(), new[] {
                "*****@*****.**",
                "*****@*****.**"
            }, "Обращение с формы обратной связи");

            var mes = new SxVMResultMessage("Ваше письмо успешно отправлено", SxVMResultMessage.ResultMessageType.Ok);

            if (!result)
            {
                mes.Message     = "Ошибка отправки сообщения. Попробуйте еще раз";
                mes.MessageType = SxVMResultMessage.ResultMessageType.Error;
            }
            ViewBag.Message = mes;
            ;
            return(View(model: new SxVMSiteQuestion()));
        }
        public async Task<ViewResult> Edit(SxVMSiteQuestion model)
        {
            if (ModelState.IsValid)
            {
                var smtpUserName = ConfigurationManager.AppSettings["NoReplyMail"];
                var mm = new SxAppMailManager(smtpUserName, ConfigurationManager.AppSettings["NoReplyMailPassword"], "mail.game-exe.com");

                var sb = new StringBuilder();
                sb.AppendLine(model.Email);
                sb.AppendLine(model.UserName);
                sb.AppendLine(model.Text);

                var result= await mm.SendMail(model.Email, sb.ToString(), new string[] { "*****@*****.**", "*****@*****.**" }, "Обращение с формы обратной связи");

                TempData["Message"] = "Ваше письмо успешно отправлено";
                return View(model: new SxVMSiteQuestion());
            }
            return View(model);
        }
Пример #3
0
        private static async Task <bool> SendMail(VMQuestion model)
        {
            var smtpUserName = ConfigurationManager.AppSettings["NoReplyMail"];
            var mm           = new SxAppMailManager(smtpUserName, ConfigurationManager.AppSettings["NoReplyMailPassword"], "mail.valliulina.ru");

            var sb = new StringBuilder();

            sb.AppendLine(model.Name);
            sb.AppendLine(model.Text);
            sb.AppendLine(model.Email);
            sb.AppendLine(model.Phone);

            var email = "*****@*****.**";

#if DEBUG
            email = "*****@*****.**";
#endif

            return(await mm.SendMail(sb.ToString(), new string[] { email }, "Обращение с формы обратной связи"));
        }