I want to send text, title of username into an email that I have but how do I add these options so I can call them over to the html file a bit like this here.
MailDefinition oMailDefinition = new MailDefinition();
oMailDefinition.BodyFileName = "~/img/emailskabelon/NewPassword.html";
oMailDefinition.From = Mail;
Dictionary<string, string> oReplacements = new Dictionary<string, string>();
oReplacements.Add("<<name>>", name);
oReplacements.Add("<<password>>", password);
I would therefore like to add some of the values that I would like to have in my html file.
It might be that I should send text, username and other things to the html file and I would like that option.
public async static void Sendmail(string email, string name, string Title, string htmlContent)
{
var api = AzureName;
var client = new SendGridClient(api);
var from = new EmailAddress(Mail, nameFrom);
var to = new EmailAddress(email, name);
var plainTextContent = Regex.Replace(htmlContent, "<[^>]*>", "");
var msg = MailHelper.CreateSingleEmail(from, to, Title, plainTextContent, htmlContent);
var response = client.SendEmailAsync(msg);
await Task.Delay(4255);
}
@model.User.FirstName @model.User.LastName
` etc, then make a model object in C#, like `var model = new MyModel{ User = new User { FirstName = "Jamie", LastName = "Twells" } }` then do something like (I forget the exact syntax) `var myHtml = Razor.Render("path/to/razor/file", model);` and it gives you the html as a string with the variables replaced. – Jamie Twells Feb 12 '18 at 22:11