Class Email<TModel>
Base class for strongly typed transactional emails. Subclasses configure the message (sender, recipients, subject, and either a named template or an inline body) in their constructor and carry a model used to render it.
public abstract class Email<TModel>
Type Parameters
TModel
- Inheritance
-
Email<TModel>
- Inherited Members
Constructors
Email(TModel)
Creates an email bound to a model instance.
protected Email(TModel model)
Parameters
modelTModel
Properties
Attachments
Attachments and inline images.
public IReadOnlyList<EmailAttachment> Attachments { get; }
Property Value
Bcc
The blind-carbon-copy recipients.
public IReadOnlyList<EmailRecipient> Bcc { get; }
Property Value
Cc
The carbon-copy recipients.
public IReadOnlyList<EmailRecipient> Cc { get; }
Property Value
From
The sender address (optional when a global default is configured).
public EmailAddress? From { get; }
Property Value
Headers
Custom message headers.
public IReadOnlyDictionary<string, string> Headers { get; }
Property Value
InlineHtml
An inline HTML template (used when no named template is set).
public string? InlineHtml { get; }
Property Value
InlineText
An inline plain-text template (used when no named template is set).
public string? InlineText { get; }
Property Value
Model
The model used to render this email's templates.
public TModel Model { get; }
Property Value
- TModel
Priority
The message importance level.
public EmailPriority Priority { get; }
Property Value
Subject
The message subject.
public string? Subject { get; }
Property Value
Tags
Tags used for routing and analytics.
public IReadOnlyDictionary<string, string> Tags { get; }
Property Value
TemplateName
The name of a registered template used to render this email.
public string? TemplateName { get; }
Property Value
To
The primary recipients.
public IReadOnlyList<EmailRecipient> To { get; }
Property Value
Methods
AddBcc(EmailAddress)
Adds a blind-carbon-copy recipient.
protected Email<TModel> AddBcc(EmailAddress address)
Parameters
addressEmailAddress
Returns
- Email<TModel>
AddBcc(string, string?)
Adds a blind-carbon-copy recipient.
protected Email<TModel> AddBcc(string address, string? displayName = null)
Parameters
Returns
- Email<TModel>
AddCc(EmailAddress)
Adds a carbon-copy recipient.
protected Email<TModel> AddCc(EmailAddress address)
Parameters
addressEmailAddress
Returns
- Email<TModel>
AddCc(string, string?)
Adds a carbon-copy recipient.
protected Email<TModel> AddCc(string address, string? displayName = null)
Parameters
Returns
- Email<TModel>
AddHeader(string, string)
Adds a custom message header.
protected Email<TModel> AddHeader(string name, string value)
Parameters
Returns
- Email<TModel>
AddTag(string, string)
Adds a tag used for routing and analytics.
protected Email<TModel> AddTag(string name, string value)
Parameters
Returns
- Email<TModel>
AddTo(EmailAddress)
Adds a primary recipient.
protected Email<TModel> AddTo(EmailAddress address)
Parameters
addressEmailAddress
Returns
- Email<TModel>
AddTo(string, string?)
Adds a primary recipient.
protected Email<TModel> AddTo(string address, string? displayName = null)
Parameters
Returns
- Email<TModel>
Attach(EmailAttachment)
Adds an attachment or inline image.
protected Email<TModel> Attach(EmailAttachment attachment)
Parameters
attachmentEmailAttachment
Returns
- Email<TModel>
SetFrom(EmailAddress)
Sets the sender address.
protected Email<TModel> SetFrom(EmailAddress from)
Parameters
fromEmailAddress
Returns
- Email<TModel>
SetFrom(string, string?)
Sets the sender address from a raw address string.
protected Email<TModel> SetFrom(string address, string? displayName = null)
Parameters
Returns
- Email<TModel>
SetHtml(string)
Sets an inline HTML template using {{Property.Path}} placeholders.
protected Email<TModel> SetHtml(string template)
Parameters
templatestring
Returns
- Email<TModel>
SetPriority(EmailPriority)
Sets the message importance level.
protected Email<TModel> SetPriority(EmailPriority priority)
Parameters
priorityEmailPriority
Returns
- Email<TModel>
SetSubject(string)
Sets the message subject.
protected Email<TModel> SetSubject(string subject)
Parameters
subjectstring
Returns
- Email<TModel>
SetText(string)
Sets an inline plain-text template using {{Property.Path}} placeholders.
protected Email<TModel> SetText(string template)
Parameters
templatestring
Returns
- Email<TModel>
UseTemplate(string)
Selects a named template registered on the MailForge builder.
protected Email<TModel> UseTemplate(string templateName)
Parameters
templateNamestring
Returns
- Email<TModel>