Mar 17 2025
dotnet add package FluentEmail.Core dotnet add package FluentEmail.Smtp
var email = await Email .From("stefan@gmail.com") .To("milan@gmail.com", "Milan") .Subject("Hi Milan!") .Body("Works!") .SendAsync();
builder.Services. .AddFluentEmail("from@gmail.com") .AddRazorRenderer() .AddSmtpSender("localhost", 25);
public class EmailService : IEmailService { private readonly IFluentEmail _fluentEmail; public EmailService(IFluentEmail fluentEmail) { _fluentEmail = fluentEmail; } public async Task Send() { await _fluentEmail .To("test@gmail.com") .Subject("Test email") .Body("Test body") .SendAsync(); } }
dotnet add package FluentEmail.Razor
//configure the Razor Renderer builder.Services .AddFluentEmail("from@gmail.com") //pass in a type in the assemble with embedded tempaltes .AddRazorRenderer(typeof(Program)) //In your template code include a layout file //the template could be sourced from file/embedded if that is configured var template = @" @{Layout = ""./Shared/_Layout.cshtml""; } Hi @Model.Name here is a list @foreach(var i in Model.Numbers) { @i }"; var model = new { Name = "Stefan", Numbers = new [] { 1, 2, 3} }; var email = new Email() .To("test@gmail.com") .Subject("Razor template example") .UsingTemplate(template, model);
dotnet add package FluentEmail.SendGrid
builder.Services .AddFluentEmail("from@gmail.com") .AddSendGridSender("apikey");
1. Design Patterns that Deliver
This isn’t just another design patterns book. Dive into real-world examples and practical solutions to real problems in real applications.Check out it here.
Go-to resource for understanding the core concepts of design patterns without the overwhelming complexity. In this concise and affordable ebook, I've distilled the essence of design patterns into an easy-to-digest format. It is a Beginner level. Check out it here.
Every Monday morning, I share 1 actionable tip on C#, .NET & Arcitecture topic, that you can use right away.
Join 18,000+ subscribers to improve your .NET Knowledge.
Subscribe to the TheCodeMan.net and be among the 18,000+ subscribers gaining practical tips and resources to enhance your .NET expertise.