Tutorials
If you have not read it yet, start with Introduction.
Send a custom email from your code
Before you run this, complete Email in the Admin Panel for the relevant culture (Settings — Tutorials: Email). Then inject IEmailService and call Send with a recipient address, subject, and body.
The following example shows the idea in a small handler-style class: it sends a one-off welcome message to a sample address. Place equivalent code in your project (for example a MediatR handler, minimal API endpoint, or background job) and replace the address with a real recipient.
using CodeBlock.DevKit.Application.Services;
public sealed class WelcomeEmailSender
{
private readonly IEmailService _email;
public WelcomeEmailSender(IEmailService email) => _email = email;
public Task NotifySampleUserAsync()
{
const string to = "[email protected]"; // replace with a real address
const string subject = "Welcome";
const string body = "<p>Thanks for signing up — your account is ready.</p>";
return _email.Send(to, subject, body, isBodyHtml: true);
}
}
For the contract details, see Services.