0

I am trying to write a windows services that will generate email based on HTML templates. I want my HTML templates to be included in my project as resources. Do i have read these these template files as using filestreams or are there built in C# functions to read these files as resources.

Is there better way to use HTML files as templates for generating emails in asp .net

Thanks SCS

CSC
  • 1,175
  • 3
  • 11
  • 24

1 Answers1

0

You just need to create resource file (.resx), then fill it in key/value manner like key = "email_template", value = "your html template". And after you will have the class with the field called email_template, and it will provide you your html template without any additional coding.


UPD

O, also you could save your template like asp.net user control (*.ascx) and then render it to string with technique described in this article

The same variant possible in MVC world. It could be done this way

Community
  • 1
  • 1
Ph0en1x
  • 9,943
  • 8
  • 48
  • 97
  • the problem is that i don't want the HTML to be in value. I want the HTML content to be a HTML file that can be easily edited. Maintaining HTML content in resource file's(.resx) value is not easy. – CSC Jan 29 '13 at 22:54
  • Then there are no way to use it right out of the box. You could store it in separate file, but it will take some simple coding to work with it. But you could use variant with resx file, but made some changes with help of Notepad ++ or Visual Studio. Of course it will take you two additional copy/paste action each time you will be edit your template. But it also a variant. – Ph0en1x Jan 29 '13 at 22:56
  • By the way - do you usnig ASP.NET or ASP.NET MVC? I;m asking because in MVC you could render view in string, possible there are some pretty the same options in Web Forms – Ph0en1x Jan 29 '13 at 23:00