Mitc.Email.Templating 1.0.0
Mitc.Email.Templating
Blazor-based email templating service with strongly-typed models and integrated sending via Mitc.Email.Abstractions.
Features
- Blazor component rendering — author email templates as Razor components and render them to HTML strings via
HtmlRenderer. - Typed template base class —
EmailTemplateBase<TModel>gives each template a strongly-typedModelparameter. - Responsive email layout —
EmailLayoutprovides a production-ready HTML email structure with optional heading, header image, footer links, and logo. - Theming —
EmailThemecontrols page/card background colors, text color, accent color, logo, and header image. Bind defaults from configuration or set per-request. - Integrated sending —
TemplatedMailServicerenders a component and sends the result throughMailServicein a single call.
Registration
builder.AddMitcMailTemplating<MyMailService>();
builder.AddMitcSendGridTransport(); // or another IMailTransport
This registers MailSettings (bound from MailSettings config section), EmailTheme (bound from MailSettings:Branding), HtmlRenderer, MailService, and your TemplatedMailService subclass.
Configuration
{
"MailSettings": {
"ServiceMode": "SendAll",
"FromAddress": "no-reply@example.com",
"Branding": {
"AccentColor": "#0066cc",
"LogoUrl": "https://example.com/logo.png"
}
}
}
Usage
1. Define a request model
public class WelcomeMailRequest : SendTemplatedMailRequest
{
public required string ActivationUrl { get; init; }
}
2. Create a Razor template
@inherits EmailTemplateBase<WelcomeMailRequest>
<EmailLayout Model="Model">
<p style="margin: 0 0 16px;">Click the link below to activate your account.</p>
<a href="@Model.ActivationUrl">Activate Account</a>
</EmailLayout>
3. Subclass the service
public class MyMailService(HtmlRenderer htmlRenderer, MailService mailService, IOptions<EmailTheme> themeOptions)
: TemplatedMailService(htmlRenderer, mailService, themeOptions)
{
public Task SendWelcomeAsync(WelcomeMailRequest model)
=> SendEmailAsync<WelcomeEmail, WelcomeMailRequest>(model);
}
Showing the top 20 packages that depend on Mitc.Email.Templating.
| Packages | Downloads |
|---|---|
|
Mitc.Email.Templates.Identity
Blazor-based email templates for ASP.NET Core Identity scenarios including email confirmation, password reset, and two-factor authentication.
|
4 |
.NET 8.0
- Mitc.Email.Abstractions (>= 1.0.0)
.NET 9.0
- Mitc.Email.Abstractions (>= 1.0.0)
.NET 10.0
- Mitc.Email.Abstractions (>= 1.0.0)
| Version | Downloads | Last updated |
|---|---|---|
| 1.0.0 | 4 | 2/20/2026 |