public ActionResult TestEmailTemplate()
{
return View();
}
[HttpPost]
public ActionResult TestEmailTemplate(string fortest)
{
ParsingTemplate();
return View();
}
private void ParsingTemplate()
{
string templateFilePath = System.Web.HttpContext.Current.Server.MapPath("~/EmailTemplates/EmailTemplateTest.html");
var templateAsString = System.IO.File.ReadAllText(templateFilePath);
var myViewModel = new TestEmailTemplateViewModel
{
UserFullName = "Mohamed Nady",
UserName = "NADY",
SiteUrl = "http://www.mohnady.com",
RegDate = DateTime.Now.ToString()
};
var body = RazorEngine.Engine.Razor.RunCompile(templateAsString, "templateKey", typeof(TestEmailTemplateViewModel), myViewModel);
SendEmail("naadydev@gmail.com", "m.nady@najran.gov.sa", "testEmail", body);
}
private void SendEmail(string from, string to, string subject, string body)
{
}
What I have tried:
hi frnds,
i am trying Asp.Net MVC Razor Email Template..i have give above my code.in that I am getting 3 Error.
1.cannot convert from 'string' to 'System.IO.TextWriter'
2. cannot convert from 'string' to 'RazorEngine.Templating.ITemplateKey'
3.Error:The best overloaded method match for 'RazorEngine.Templating.IRazorEngineService.RunCompile(RazorEngine.Templating.ITemplateKey, System.IO.TextWriter, System.Type, object, RazorEngine.Templating.DynamicViewBag)' has some invalid arguments
And,am getting Error This Line itself
var body = RazorEngine.Engine.Razor.RunCompile(templateAsString, "templateKey", typeof(TestEmailTemplateViewModel), myViewModel);
Please help me For this