Table of Contents

Class EmailMessage

Namespace
MailForge.Models
Assembly
MailForge.dll

An immutable, provider-agnostic email message. This is the payload exchanged between the framework, the middleware pipeline, and every IEmailProvider.

public sealed class EmailMessage
Inheritance
EmailMessage
Inherited Members

Constructors

EmailMessage(EmailAddress, IEnumerable<EmailRecipient>, string?, string?, string?, EmailPriority, IEnumerable<EmailAttachment>?, IDictionary<string, string>?, IDictionary<string, string>?, string?)

Creates a new message.

public EmailMessage(EmailAddress from, IEnumerable<EmailRecipient> recipients, string? subject, string? htmlBody = null, string? textBody = null, EmailPriority priority = EmailPriority.Normal, IEnumerable<EmailAttachment>? attachments = null, IDictionary<string, string>? headers = null, IDictionary<string, string>? tags = null, string? messageId = null)

Parameters

from EmailAddress
recipients IEnumerable<EmailRecipient>
subject string
htmlBody string
textBody string
priority EmailPriority
attachments IEnumerable<EmailAttachment>
headers IDictionary<string, string>
tags IDictionary<string, string>
messageId string

Properties

Attachments

Attachments and inline images.

public IReadOnlyList<EmailAttachment> Attachments { get; }

Property Value

IReadOnlyList<EmailAttachment>

BccRecipients

The blind-carbon-copy (Bcc) recipients.

public IReadOnlyList<EmailRecipient> BccRecipients { get; }

Property Value

IReadOnlyList<EmailRecipient>

CcRecipients

The carbon-copy (Cc) recipients.

public IReadOnlyList<EmailRecipient> CcRecipients { get; }

Property Value

IReadOnlyList<EmailRecipient>

CreatedAt

The time at which the message was created.

public DateTimeOffset CreatedAt { get; }

Property Value

DateTimeOffset

From

The sender of the message.

public EmailAddress From { get; }

Property Value

EmailAddress

Headers

Custom message headers.

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

Property Value

IReadOnlyDictionary<string, string>

HtmlBody

The HTML body (may be null when only a plain-text body is provided).

public string? HtmlBody { get; }

Property Value

string

MessageId

A unique identifier for this message (used by auditing and delivery tracking).

public string MessageId { get; }

Property Value

string

Priority

The message importance level.

public EmailPriority Priority { get; }

Property Value

EmailPriority

Recipients

All recipients, each tagged with its role (To, Cc, or Bcc).

public IReadOnlyList<EmailRecipient> Recipients { get; }

Property Value

IReadOnlyList<EmailRecipient>

Subject

The message subject.

public string? Subject { get; }

Property Value

string

Tags

Arbitrary key/value tags used for routing and analytics.

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

Property Value

IReadOnlyDictionary<string, string>

TextBody

The plain-text body (may be null when only an HTML body is provided).

public string? TextBody { get; }

Property Value

string

ToRecipients

The primary (To) recipients.

public IReadOnlyList<EmailRecipient> ToRecipients { get; }

Property Value

IReadOnlyList<EmailRecipient>

Methods

Create()

Returns a fluent builder for constructing a message.

public static EmailMessageBuilder Create()

Returns

EmailMessageBuilder