Table of Contents

Class MailPart

Namespace
NuvTools.Notification.Mail
Assembly
NuvTools.Notification.Mail.dll

Represents an email attachment with media type, extension, and content stream.

public class MailPart
Inheritance
MailPart
Inherited Members

Examples

var attachment = new MailPart
{
    MediaType = "application",
    MediaExtension = "pdf",
    FileName = "invoice.pdf",
    Content = fileStream
};

Remarks

This class is used to attach files to email messages. The content is provided as a stream, and both the media type and extension are required to properly identify the attachment format, while the file name identifies it to the recipient.

Properties

Content

Gets or sets the content stream of the attachment.

public required Stream Content { get; set; }

Property Value

Stream

ContentId

Gets or sets the optional Content-ID used to reference the attachment from the HTML body.

public string? ContentId { get; set; }

Property Value

string

Remarks

When informed, the attachment is embedded in the message and can be referenced as <img src="cid:yourContentIdHere" /> instead of being listed as a regular attachment.

FileName

Gets or sets the file name presented to the recipient (e.g., "invoice.pdf").

public required string FileName { get; set; }

Property Value

string

Remarks

Attachments sent without a name are displayed with an arbitrary name chosen by the email client (e.g., "ATT00001.pdf" or "noname"), so the file name is always required.

MediaExtension

Gets or sets the media subtype of the attachment (e.g., "pdf", "png", "plain").

public required string MediaExtension { get; set; }

Property Value

string

Remarks

Combined with MediaType it forms the MIME type of the attachment, so it is the media subtype rather than the file extension. For a Word document, the subtype is "vnd.openxmlformats-officedocument.wordprocessingml.document" while the ".docx" extension belongs to FileName.

MediaType

Gets or sets the MIME media type of the attachment (e.g., "application", "image", "text").

public required string MediaType { get; set; }

Property Value

string