I want to create a separate service for sending emails, this will be based on a .net core 3.1 application with its default layers (application, domain, contracts, infrastructure)
Within this project, I want to create a class library which holds my Razor templates and parses them so the application layer can send this as an email (both HTML and non-html) after the model has been applied, however this is where I run into a problem.
Every example I can find targets older .net core applications, which means nuget packages like RazorEngine.NetCore won't work.
Also examples as found in https://emilol.com/razor-mailer/ won't work as they target older frameworks.
A deep dive into the Razor Client Library also didn't work as I tried to adjust this sample for 3.1 https://derekarends.com/how-to-create-email-templates-with-asp-net-core-2-2/
Is there any way to make this work or do I really need to target an older framework just to create a email template library?
I was looking for a simple solution for my Blazor application recently and found this GitHub project.: BlazorTemplater
It's really simple to use.
<p>Hello, @FirstName.</p>
@code {
[Parameter]
public string FirstName { get; set; }
}
private void SendWelcomeEmail()
{
string html = new ComponentRenderer<WelcomeEmailTemplate>()
.Set(c => c.FirstName, Applicant.FirstName)
.Render();
Console.WriteLine(html);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With