How to customize the template for forms notifications email?
Hi,
I just began using the Forms Notification feature that was released with Sitefinity 5.1.
Is there any way we can create a custom email template for it? Or apply some custom styles to the default one?
Thanks,
Nidhi
Hi Nidhi,
Thank you for using our services.
To change the email template you have to replace the default one with a custom template (htm file) and set its database id to the notification config file. This can be done on an . aspx page. Simply create an htm page, which should be a copy of the default template and in the .aspx page run the following code, which will set your hmtl page, instead of the default one:
.apsx page
namespace SitefinityWebApp public partial class FormTemplate : System.Web.UI.Page protected void Page_Load(object sender, EventArgs e) var formsConfig = Config.Get<FormsConfig>(); var configManager = ConfigManager.GetManager(); formsConfig = configManager.GetSection<FormsConfig>(); var notificationService = SystemManager.GetNotificationService(); var serviceContext = this.GetServiceContext(); var messageTemplate = GetDefaultFormEntrySubmittedEmailTemplate(); var templateId = notificationService.CreateMessageTemplate(serviceContext, messageTemplate); formsConfig.Notifications.FormEntrySubmittedNotificationTemplateId = templateId; configManager.SaveSection(formsConfig); ServiceContext GetServiceContext() return new ServiceContext("ThisApplicationKey", FormsModule.ModuleName); public MessageTemplateRequestProxy GetDefaultFormEntrySubmittedEmailTemplate() var messageTemplate = new MessageTemplateRequestProxy(); messageTemplate.Subject = "New form entry is submitted"; messageTemplate.BodyHtml = Telerik.Sitefinity.Pages.Model.ControlTemplateResolver.ResolveTemplate( "SitefinityWebApp.Form.htm", "SitefinityWebApp"); return messageTemplate;