Class MimeMessage
A complete MIME message (RFC 5322). Immutable after parsing. Construct via MimeMessageBuilder for writing.
Inherited Members
Namespace: DRIT.Mail.Rfc.Mime
Assembly: DRIT.Mail.dll
Syntax
public sealed class MimeMessage
Constructors
View SourceMimeMessage(MimeHeaderCollection, MimeEntity, string?, InternetAddressList, InternetAddressList, InternetAddressList, InternetAddressList, InternetAddressList, string?, DateTimeOffset?, string?, string?, string?, string?, IReadOnlyList<MimeAttachment>)
Initializes a new instance of the MimeMessage class.
Declaration
public MimeMessage(MimeHeaderCollection headers, MimeEntity body, string? subject, InternetAddressList from, InternetAddressList to, InternetAddressList cc, InternetAddressList bcc, InternetAddressList replyTo, string? messageId, DateTimeOffset? date, string? inReplyTo, string? references, string? textBody, string? htmlBody, IReadOnlyList<MimeAttachment> attachments)
Parameters
| Type | Name | Description |
|---|---|---|
| MimeHeaderCollection | headers | |
| MimeEntity | body | |
| string | subject | |
| InternetAddressList | from | |
| InternetAddressList | to | |
| InternetAddressList | cc | |
| InternetAddressList | bcc | |
| InternetAddressList | replyTo | |
| string | messageId | |
| DateTimeOffset? | date | |
| string | inReplyTo | |
| string | references | |
| string | textBody | |
| string | htmlBody | |
| IReadOnlyList<MimeAttachment> | attachments |
Properties
View SourceAttachments
Gets the attachments of this message.
Declaration
public IReadOnlyList<MimeAttachment> Attachments { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<MimeAttachment> |
Bcc
Gets the Bcc address list.
Declaration
public InternetAddressList Bcc { get; }
Property Value
| Type | Description |
|---|---|
| InternetAddressList |
Body
Gets the body entity of this message.
Declaration
public MimeEntity Body { get; }
Property Value
| Type | Description |
|---|---|
| MimeEntity |
Cc
Gets the Cc address list.
Declaration
public InternetAddressList Cc { get; }
Property Value
| Type | Description |
|---|---|
| InternetAddressList |
Date
Gets the Date header value, or null if not present.
Declaration
public DateTimeOffset? Date { get; }
Property Value
| Type | Description |
|---|---|
| DateTimeOffset? |
From
Gets the From address list.
Declaration
public InternetAddressList From { get; }
Property Value
| Type | Description |
|---|---|
| InternetAddressList |
Headers
Gets all headers of this message.
Declaration
public MimeHeaderCollection Headers { get; }
Property Value
| Type | Description |
|---|---|
| MimeHeaderCollection |
HtmlBody
Gets the decoded HTML body (first text/html part), or null if not present.
Declaration
public string? HtmlBody { get; }
Property Value
| Type | Description |
|---|---|
| string |
InReplyTo
Gets the In-Reply-To header value, or null if not present.
Declaration
public string? InReplyTo { get; }
Property Value
| Type | Description |
|---|---|
| string |
MessageId
Gets the Message-ID header value, or null if not present.
Declaration
public string? MessageId { get; }
Property Value
| Type | Description |
|---|---|
| string |
References
Gets the References header value, or null if not present.
Declaration
public string? References { get; }
Property Value
| Type | Description |
|---|---|
| string |
ReplyTo
Gets the Reply-To address list.
Declaration
public InternetAddressList ReplyTo { get; }
Property Value
| Type | Description |
|---|---|
| InternetAddressList |
Subject
Gets the Subject header value, or null if not present.
Declaration
public string? Subject { get; }
Property Value
| Type | Description |
|---|---|
| string |
TextBody
Gets the decoded text body (first text/plain part), or null if not present.
Declaration
public string? TextBody { get; }
Property Value
| Type | Description |
|---|---|
| string |
To
Gets the To address list.
Declaration
public InternetAddressList To { get; }
Property Value
| Type | Description |
|---|---|
| InternetAddressList |
Methods
View SourceLoad(Stream)
Loads a MimeMessage from the specified stream.
Declaration
public static MimeMessage Load(Stream stream)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | The stream used to read or write the data. |
Returns
| Type | Description |
|---|---|
| MimeMessage |
Load(string)
Loads a MimeMessage from the specified file.
Declaration
public static MimeMessage Load(string fileName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | fileName | The file or path to process. |
Returns
| Type | Description |
|---|---|
| MimeMessage |
Write(Stream)
Writes this message to the specified stream.
Declaration
public void Write(Stream stream)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | The stream used to read or write the data. |
Write(string)
Writes this message to the specified file.
Declaration
public void Write(string fileName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | fileName | The file or path to process. |