Castle.MonoRail.Framework.EmailTemplateService.RenderMailMessage C# (CSharp) Method

RenderMailMessage() public method

Creates an instance of Message using the specified template for the body
public RenderMailMessage ( String templateName, IDictionary parameters, bool doNotApplyLayout ) : Message
templateName String /// Name of the template to load. /// Will look in Views/mail for that template file. ///
parameters IDictionary /// Dictionary with parameters /// that you can use on the email template ///
doNotApplyLayout bool If true, it will skip the layout
return Castle.Components.Common.EmailSender.Message
		public Message RenderMailMessage(String templateName, IDictionary parameters, bool doNotApplyLayout)
		{
			if (HttpContext.Current == null)
			{
				throw new RailsException("No http context available");
			}
			
			if (logger.IsDebugEnabled)
			{
				logger.DebugFormat("Rendering email message. Template name {0}", templateName);
			}

			IRailsEngineContext context = EngineContextModule.ObtainRailsEngineContext(HttpContext.Current);

			Controller controller = context.CurrentController;

			if (controller == null)
			{
				throw new RailsException("No controller found on the executing activity");
			}

			if (parameters != null && parameters.Count != 0)
			{
				foreach(DictionaryEntry entry in parameters)
				{
					controller.PropertyBag.Add(entry.Key, entry.Value);
				}
			}

			try
			{
				return RenderMailMessage(templateName, context, controller, doNotApplyLayout);
			}
			finally
			{
				if (parameters != null && parameters.Count != 0)
				{
					foreach(DictionaryEntry entry in parameters)
					{
						controller.PropertyBag.Remove(entry.Key);
					}
				}
			}
		}

Same methods

EmailTemplateService::RenderMailMessage ( String templateName, IRailsEngineContext context, Controller controller, bool doNotApplyLayout ) : Message