Beispiel #1
0
        public ActionResult NotExecCourrier()
        {
            var q = enregRepository.GetNotExecEnreg(EnregTypeID);

            if (q.Count > 0)
            {
                SmtpClient  sc      = new SmtpClient();
                MailMessage message = new MailMessage();
                message.From = new MailAddress(ConfigurationManager.AppSettings["EMailFrom"], "Внутренний контроль");
                message.To.Add(((HttpContext.Request).Url.Authority.Contains("localhost")) ? "*****@*****.**" : _configProvider.GetValue <string>("NotExecCourrier"));
                //message.CC.Add("*****@*****.**");
                message.Body       = RenderViewToString(ControllerContext, "~/Areas/Code/Views/enreg/NotExecCourrier.cshtml", q);
                message.IsBodyHtml = true;
                message.Priority   = MailPriority.High;
                message.Headers.Add("Importance", "High");
                message.IsBodyHtml = true;
                message.Subject    = "Неисполненные поручения клиентов";
                try
                {
                    sc.Send(message);
                }
                catch (Exception ex)
                {
                    return(new JsonnResult {
                        Data = new { success = false, message = ex.Message }
                    });
                }
            }
            return(new JsonnResult {
                Data = new { success = true }
            });
        }