public ActionResult Index(string mode, string topic_code, string dept = null) { try{ ViewBag.Mode = mode; // if(Topic.Type == "ERR0R"){ Topic = M_Mail.GetTopicByCode(topic_code); // } // ViewBag.Url = $"https://17.27.170.19/ChangeControl/Detail/Index/?id={Topic.Code}"; ViewBag.Url = $"{Request.Url.Host}:{Request.Url.Port}/{Request.ApplicationPath}/Detail/Index/?id={Topic.Code}"; ViewBag.Topic = Topic; ViewBag.DueDate = DateTime.Now.DueDateOn(10); var email = RenderView("~/Views/Mail/index.cshtml", Topic); var related_list = M_Mail.GetRelatedByTopicCode(topic_code); Type type = related_list.GetType(); PropertyInfo[] props = type.GetProperties(); var address_list = new List <string>(); foreach (var prop in props) { if ((int)prop.GetValue(related_list) == 1) { address_list.AddRange(M_Mail.GetEmailByDept(prop.Name)); } } SendMail(email, address_list); // return Json(new {status = true}, JsonRequestBehavior.AllowGet); return(View(Topic)); }catch (Exception err) { return(Json(new { error = err }, JsonRequestBehavior.AllowGet)); } }