Table of Contents

Class EmailAttachment

Namespace
MailForge.Models
Assembly
MailForge.dll

An attachment (or inline image) attached to an email message.

public sealed class EmailAttachment
Inheritance
EmailAttachment
Inherited Members

Constructors

EmailAttachment(string, byte[], string?, bool, string?)

Creates an attachment from a byte array.

public EmailAttachment(string fileName, byte[] content, string? mediaType = null, bool isInline = false, string? contentId = null)

Parameters

fileName string
content byte[]
mediaType string
isInline bool
contentId string

EmailAttachment(string, Stream, string?, bool, string?)

Creates an attachment by reading all bytes from a stream.

public EmailAttachment(string fileName, Stream content, string? mediaType = null, bool isInline = false, string? contentId = null)

Parameters

fileName string
content Stream
mediaType string
isInline bool
contentId string

Properties

Content

The attachment content bytes.

public byte[] Content { get; }

Property Value

byte[]

ContentId

The content id used to reference inline images (cid:value) from the HTML body.

public string? ContentId { get; }

Property Value

string

FileName

The file name of the attachment.

public string FileName { get; }

Property Value

string

IsInline

True when the attachment is an inline image referenced via a content id (cid:).

public bool IsInline { get; }

Property Value

bool

MediaType

The MIME media type (for example, "application/pdf").

public string MediaType { get; }

Property Value

string

Methods

FromFile(string, string?, bool, string?)

Creates an attachment from a file on disk.

public static EmailAttachment FromFile(string path, string? mediaType = null, bool isInline = false, string? contentId = null)

Parameters

path string
mediaType string
isInline bool
contentId string

Returns

EmailAttachment

GuessMediaType(string)

Infers a MIME media type from a file name extension.

public static string GuessMediaType(string fileName)

Parameters

fileName string

Returns

string