Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8821499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:52:13+00:00 2026-06-14T05:52:13+00:00

I’m trying to use RazorGenerator as an email template engine. I want to take

  • 0

I’m trying to use RazorGenerator as an email template engine. I want to take a model with the data, assemble the correct set of partial views, and return HTML that I can email out.
Edit: In addition to this workflow, any solution would need to be editable as a .cshtml file and be able to be compiled into a dll. For various reasons, it is not practical to deploy the cshtml files themselves – if we can’t embed all our razor views into a single file, then we can’t use that suggestion. Hence RazorGenerator.

So far, I’ve worked out every part of it, except for the partials. When I try to use @Html.Partial() in a template file, I get: The name 'Html' does not exist in the current context.

Based on this answer, I know that @Html isn’t part of Razor by default, and there’s many answers out there as to how to create a HtmlHelper in a controller. However, I need to create one in a template, which doesn’t have the ControllerContext that I’d need to follow those examples.

I’ve also tried using @Include, but the RazorGenerator template doesn’t seem to support that. Edit: I also tried creating a new class which inherited from TemplateBase<> and copied all the functionality of RazorTemplateBase, but I get NullReferenceExceptions on the @Include line.

So, my primary question is: Is there a better way to include another Razor file (with model) into my file?

Secondarily, if there isn’t a better way, how can I get the HtmlHelper created?


Edit for bounty: Just to reiterate, the four things I need in an acceptable answer are:

  1. The ability to edit .cshtml files with the standard editor (no “store it as a string” or such)
  2. The ability to compile everything into a single dll which can be deployed using our current build system (we can’t deploy lots of individual .cshtml’s)
  3. The ability to reference one .cshtml file from another, and pass a model – equivalent to @Includes or @Html.Partial (Either of which are perfectly acceptable if they work)
  4. The ability to email out the result, with attachments. (I already have code for this, if the result is a string or convertible to one.)

I currently can get most combinations of three of these working, but I can’t get all four at once. I’m open to new libraries, replacing RazorGenerator, or throwing out any part of what I already have, so long as the result works as needed.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T05:52:14+00:00Added an answer on June 14, 2026 at 5:52 am

    Just a thought, but why couldn’t you set up other pages and in your Controller Code open up an HTTPWebRequest / WebClient send the data you need there, get all the html/text out of that view, merge several calls together and then email out all that string.

    public ActionResult SomeAction() {
      // call other section logic using HttpWebRequest or WebClient
      // /controller/emailsection/{vars}/......
      // Get the string out of the request add it to ViewData["xxx"]
      // rinse and repeat for other sections
    
    }
    
    public ActionResult EmailSection() {
      //put section logic here
    
      Response.ContentType = "text/html"; // "text/plain"
      Response.Write("Some HttpWebResponse");
      return null;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I want use html5's new tag to play a wav file (currently only supported
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I want to construct a data frame in an Rcpp function, but when I
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.