Table of Contents

Class Email<TModel>

Namespace
MailForge.Models
Assembly
MailForge.dll

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

model TModel

Properties

Attachments

Attachments and inline images.

public IReadOnlyList<EmailAttachment> Attachments { get; }

Property Value

IReadOnlyList<EmailAttachment>

Bcc

The blind-carbon-copy recipients.

public IReadOnlyList<EmailRecipient> Bcc { get; }

Property Value

IReadOnlyList<EmailRecipient>

Cc

The carbon-copy recipients.

public IReadOnlyList<EmailRecipient> Cc { get; }

Property Value

IReadOnlyList<EmailRecipient>

From

The sender address (optional when a global default is configured).

public EmailAddress? From { get; }

Property Value

EmailAddress

Headers

Custom message headers.

public IReadOnlyDictionary<string, string> Headers { get; }

Property Value

IReadOnlyDictionary<string, string>

InlineHtml

An inline HTML template (used when no named template is set).

public string? InlineHtml { get; }

Property Value

string

InlineText

An inline plain-text template (used when no named template is set).

public string? InlineText { get; }

Property Value

string

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

EmailPriority

Subject

The message subject.

public string? Subject { get; }

Property Value

string

Tags

Tags used for routing and analytics.

public IReadOnlyDictionary<string, string> Tags { get; }

Property Value

IReadOnlyDictionary<string, string>

TemplateName

The name of a registered template used to render this email.

public string? TemplateName { get; }

Property Value

string

To

The primary recipients.

public IReadOnlyList<EmailRecipient> To { get; }

Property Value

IReadOnlyList<EmailRecipient>

Methods

AddBcc(EmailAddress)

Adds a blind-carbon-copy recipient.

protected Email<TModel> AddBcc(EmailAddress address)

Parameters

address EmailAddress

Returns

Email<TModel>

AddBcc(string, string?)

Adds a blind-carbon-copy recipient.

protected Email<TModel> AddBcc(string address, string? displayName = null)

Parameters

address string
displayName string

Returns

Email<TModel>

AddCc(EmailAddress)

Adds a carbon-copy recipient.

protected Email<TModel> AddCc(EmailAddress address)

Parameters

address EmailAddress

Returns

Email<TModel>

AddCc(string, string?)

Adds a carbon-copy recipient.

protected Email<TModel> AddCc(string address, string? displayName = null)

Parameters

address string
displayName string

Returns

Email<TModel>

AddHeader(string, string)

Adds a custom message header.

protected Email<TModel> AddHeader(string name, string value)

Parameters

name string
value string

Returns

Email<TModel>

AddTag(string, string)

Adds a tag used for routing and analytics.

protected Email<TModel> AddTag(string name, string value)

Parameters

name string
value string

Returns

Email<TModel>

AddTo(EmailAddress)

Adds a primary recipient.

protected Email<TModel> AddTo(EmailAddress address)

Parameters

address EmailAddress

Returns

Email<TModel>

AddTo(string, string?)

Adds a primary recipient.

protected Email<TModel> AddTo(string address, string? displayName = null)

Parameters

address string
displayName string

Returns

Email<TModel>

Attach(EmailAttachment)

Adds an attachment or inline image.

protected Email<TModel> Attach(EmailAttachment attachment)

Parameters

attachment EmailAttachment

Returns

Email<TModel>

SetFrom(EmailAddress)

Sets the sender address.

protected Email<TModel> SetFrom(EmailAddress from)

Parameters

from EmailAddress

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

address string
displayName string

Returns

Email<TModel>

SetHtml(string)

Sets an inline HTML template using {{Property.Path}} placeholders.

protected Email<TModel> SetHtml(string template)

Parameters

template string

Returns

Email<TModel>

SetPriority(EmailPriority)

Sets the message importance level.

protected Email<TModel> SetPriority(EmailPriority priority)

Parameters

priority EmailPriority

Returns

Email<TModel>

SetSubject(string)

Sets the message subject.

protected Email<TModel> SetSubject(string subject)

Parameters

subject string

Returns

Email<TModel>

SetText(string)

Sets an inline plain-text template using {{Property.Path}} placeholders.

protected Email<TModel> SetText(string template)

Parameters

template string

Returns

Email<TModel>

UseTemplate(string)

Selects a named template registered on the MailForge builder.

protected Email<TModel> UseTemplate(string templateName)

Parameters

templateName string

Returns

Email<TModel>