public virtual EmailResult Email(string viewName, object model = null, string masterName = null,
                                         bool trimBody = true)
        {
            if (viewName == null)
            {
                throw new ArgumentNullException("viewName");
            }

            var result = new EmailResult(this, MailSender, MailAttributes, viewName, masterName,
                                         MailAttributes.MessageEncoding, trimBody);

            ViewData.Model  = model;
            result.ViewData = ViewData;

            var routeData = new RouteData();

            routeData.DataTokens["area"]   = FindAreaName();
            routeData.Values["controller"] = GetType().Name.Replace("Controller", string.Empty);
            routeData.Values["action"]     = viewName;

            var requestContext = new RequestContext(HttpContextBase, routeData);

            ControllerContext = new ControllerContext(requestContext, this);

            result.ExecuteResult(ControllerContext);
            return(result);
        }
Example #2
0
        public virtual EmailResult Email(string viewName, object model = null, string masterName = null,
            bool trimBody = true)
        {
            if (viewName == null)
                throw new ArgumentNullException("viewName");

            var result = new EmailResult(this, MailSender, MailAttributes, viewName, masterName,
                MailAttributes.MessageEncoding, trimBody);
            ViewData.Model = model;
            result.ViewData = ViewData;

            var routeData = new RouteData();
            routeData.DataTokens["area"] = FindAreaName();
            routeData.Values["controller"] = GetType().Name.Replace("Controller", string.Empty);
            routeData.Values["action"] = viewName;

            var requestContext = new RequestContext(HttpContextBase, routeData);
            ControllerContext = new ControllerContext(requestContext, this);

            result.ExecuteResult(ControllerContext);
            return result;
        }