I am busy with trying to greet a person in the email, this email body is made from an html script but the issue i am having is that it prints out the variable name instead of the value itself. Here is my controller:
public async Task<IHttpActionResult> EmailReport([FromUri] ReportRequestViewModel request)
{
var reportEmailViewModel = new ReportEmailViewModel();
reportEmailViewModel.Name = CurrentUser.Name;
reportEmailViewModel.ScorecardName = _BEEScorecardService.GetById(request.ScorecardId).Name;
var pdf = GetFileAsResponseMessage(docStream.ToArray(), report.FileName, true);
var encoding = new System.Text.UTF8Encoding();
var newReportEmail = new ReportEmailModel()
{
ToRecieverEmailAddress = CurrentUser.Email,
Body = (System.IO.File.ReadAllText(HttpContext.Current.Server.MapPath("/Views/EmailTemplate/")+ "ReportEmail.cshtml", encoding)),
attachment = pdf
};
_EmailService.SendReportEmail(newReportEmail);
return Ok();
}
My viewmodel for the persons name and other details:
public class ReportEmailViewModel
{
public string Name { get; set; }
public string ScorecardName { get; set; }
}
and my chtml(I cut out some of the html to show exactly where the error is occuring):
@model BEE123.Web.UI.ViewModel.ReportEmailViewModel
<!DOCTYPE html>
<html>
<body>
<div align='center'>
<table class='MsoNormalTable' style='width:462.0pt;mso-cellspacing:1.5pt;mso-yfti-tbllook:1184' width='616'
cellspacing='3' cellpadding='0' border='0'>
<tbody>
<tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes;mso-yfti-lastrow:yes'>
<td style='padding:.75pt .75pt .75pt .75pt'>
<p class='MsoNormal'>
<span style='font-size:8.5pt;font-family:"Segoe UI",sans-serif;mso-fareast-font-family:"Times New Roman"'>
<img id='_x0000_i1025'
src='http://app.bee123.co.za/Images/BEE123EmailBanner.PNG' ?=''>
</span>
</p>
<h1>
<span style='font-family:"Segoe UI",sans-serif;mso-fareast-font-family:"Times New Roman";color:#B8995F'>Scorecard Report</span>
</h1>
<p>
<span style='font-size:8.5pt;font-family:"Segoe UI",sans-serif'>
Hi @Model.Name
</span>
</p>