Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • René Pjengaard 118 posts 701 karma points c-trib
    20 days ago
    René Pjengaard
    0

    Issue with "Send Email with Template (Razor)" Workflow in Umbraco Forms

    I am encountering an issue when trying to use the "Send email with template (razor)" workflow in Umbraco Forms. The problem occurs when I specify a custom Razor view for the email template, leading to the following error message:

    Error parsing record with Razor view - /Views/Partials/Forms/Emails/EmailTemplateEmpty.cshtml
    

    Stacktrace:

        System.InvalidOperationException: Could not render view to string. Controller: Umbraco.Forms.Core.Controllers.RazorEmailViewController, View Path: /Views/Partials/Forms/Emails/EmailTemplateEmpty.cshtml.
       at Umbraco.Forms.Web.Extensions.ControllerExtensions.RenderViewAsync[TModel](Controller controller, String viewPath, TModel model)
       at Umbraco.Forms.Core.Providers.WorkflowTypes.SendRazorEmail.ParseWithRazorView(Record record, String razorViewFilePath)
       at Umbraco.Forms.Core.Providers.WorkflowTypes.SendRazorEmail.Execute(WorkflowExecutionContext context)
    

    However, when I use the built-in template Example-Template.cshtml, the workflow functions as expected without any issues. The problem arises when I try to use a template based on the example provided in the documentation (Umbraco Forms Documentation - Email Templates). I have also tried to add a template from an existing and working solution with the same result.

    Even after clearing the template of all custom logic, leaving it as plain HTML, the issue persists. It seems like the Razor view is not being parsed correctly in the custom template path.

    Could you help me identify what might be causing this issue or provide guidance on how to get custom Razor templates working for email workflows?

    Environment:

    Umbraco Forms Version: 12.2.4

    Umbraco Version: 12.3.10

    Minimum template

    @inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<Umbraco.Forms.Core.Models.FormsHtmlModel>
    @using System;
    @using System.Globalization;
    
    <!DOCTYPE html>
    <html>
    <head>
    
    </head>
    <body style="margin: 0 !important; padding: 0 !important;">
        <h1>test template</h1>
    </body>
    </html>
    

    Thank you for your assistance!

    Best regards, René

Please Sign in or register to post replies

Write your reply to:

Draft