MimePart Class

A leaf MIME part: a text body or an attachment.

public sealed class MimePart : MimeEntity
Inheritance
MimeEntity MimePart

Constructors

NameDescription
MimePart()Initializes a new instance of the MimePart class with no content.

MimePart()

MimePart.cs

Initializes a new instance of the MimePart class with no content.

public MimePart()

Properties

NameDescription
ContentTransferEncodingGets or sets the transfer encoding of the content, such as base64, quoted-printable or 7bit.
FileNameGets the file name: the filename parameter of the disposition, or the name parameter of the content type.
IsAttachmentGets whether the part is an attachment: its disposition is attachment.

ContentTransferEncoding

MimePart.cs

Gets or sets the transfer encoding of the content, such as base64, quoted-printable or 7bit.

public string? ContentTransferEncoding { get; set; }

Property value

string?

FileName

MimePart.cs

Gets the file name: the filename parameter of the disposition, or the name parameter of the content type.

public string? FileName { get; }

Property value

string?

IsAttachment

MimePart.cs

Gets whether the part is an attachment: its disposition is attachment.

public bool IsAttachment { get; }

Property value

bool

Methods

NameDescription
GetContent()Returns the decoded content of the part.
GetText()Returns the content decoded as text with the charset of the part (UTF-8 or Latin-1 when it has none).
SetContent(byte[])Sets the content. The writer encodes it with the transfer encoding, which it chooses when the part has none.
SetText(string, string)Sets a text content, in UTF-8.

GetContent()

MimePart.cs

Returns the decoded content of the part.

public byte[] GetContent()

Returns

byte[] The content.

GetText()

MimePart.cs

Returns the content decoded as text with the charset of the part (UTF-8 or Latin-1 when it has none).

public string GetText()

Returns

string The text.

SetContent(byte[])

MimePart.cs

Sets the content. The writer encodes it with the transfer encoding, which it chooses when the part has none.

public void SetContent(byte[] content)

Parameters

content byte[]
The content.

SetText(string, string)

MimePart.cs

Sets a text content, in UTF-8.

public void SetText(string text, string mediaSubtype = "plain")

Parameters

text string
The text.
mediaSubtype string
The subtype of text, such as plain or html.