public ActionResult Index(int?page, int?accountId, string Keyword)
        {
            var templateListVM = new EmailTemplateListVM()
            {
                AccountId = accountId ?? 0,
                PageIndex = page ?? 1,
                PageSize  = SettingsManager.EmailTemplate.PageSize,
                Keyword   = Keyword
            };
            int count;
            var templates = _templateService.GetPagedElements(templateListVM.PageIndex - 1, templateListVM.PageSize, templateListVM.Keyword, templateListVM.AccountId, out count);

            foreach (var item  in templates)
            {
                item.EmailAccount = _accountService.GetById(item.EmailAccountId);
            }
            // var templateDtos = _mapper.Map<IEnumerable<EmailTemplate>, IEnumerable<EmailTemplateVM>>(templates.AsEnumerable());
            // templateListVM.EmailTemplates = templateDtos;

            templateListVM.TotalCount = count;

            var accountList = _accountService.GetElements().OrderByDescending(c => c.Email).ToList();
            var categories  = new SelectList(accountList, "Id", "Email");

            ViewBag.Categories = categories;

            templateListVM.EmailTemplates = new StaticPagedList <EmailTemplate>(templates, templateListVM.PageIndex, templateListVM.PageSize, templateListVM.TotalCount);
            //  ViewBag.OnePageOfEmailTemplates = templatesAsIPagedList;

            ViewBag.PageSizes = new SelectList(Site.PageSizes());

            return(View(templateListVM));
        }
        public ActionResult Test(int id)
        {
            EmailAccount emailAccount = _emailAccountService.GetById(id);

            if (emailAccount == null)
            {
                AR.Setfailure(Messages.HttpNotFound);
                return(Json(AR, JsonRequestBehavior.AllowGet));
            }

            var vm = new TestEmailIM()
            {
                AccountId = emailAccount.Id
            };

            return(PartialView("_Test", vm));
        }