Skip to main content

Where templates live

All email templates are in src/Acme.Infrastructure/Email/Templates/. Each template is a C# class that extends EmailTemplateBase.

How templates work

EmailTemplateBase provides:
  • The outer HTML envelope (DOCTYPE, <head>, brand color, inline styles)
  • Header with the application name
  • Footer with unsubscribe language
  • Abstract RenderContent() method that each template implements
Each template class fills in RenderContent() with its specific body HTML:

Changing the brand color

The primary color is set in one place in EmailTemplateBase:
Change this value and it propagates to every template header, button, and accent element.

Changing email copy

Find the relevant template class, edit the string in RenderContent(). The C# raw string literal ("""...""") makes multi-line HTML easy to write and read. Replace the text-based header in EmailTemplateBase.RenderHeader() with an <img> tag:

Adding a new template

Step 1: Add a value to the EmailTemplate enum in Domain:
Step 2: Create the template class:
Step 3: Add a case in ResendEmailService.SendTemplateAsync:

Testing email rendering locally

Dump a template to HTML and open it in a browser — no SMTP server needed:
Then open /tmp/weekly-digest-preview.html in your browser. Delete this code before committing. For sends that actually went through, check the Emails tab in the Resend dashboard — it shows the full rendered HTML, delivery timestamp, and open/click events.