C# Class MimeKit.MimePart

A leaf-node MIME part that contains content such as the message body text or an attachment.
A leaf-node MIME part that contains content such as the message body text or an attachment.
Inheritance: MimeKit.MimeEntity
Exibir arquivo Open project: jstedfast/MimeKit Class Usage Examples

Public Methods

Method Description
Accept ( MimeKit.MimeVisitor visitor ) : void

Dispatches to the specific visit method for this MIME entity.

This default implementation for MimeKit.MimePart nodes calls MimeKit.MimeVisitor.VisitMimePart. Override this method to call into a more specific method on a derived visitor class of the MimeKit.MimeVisitor class. However, it should still support unknown visitors by calling MimeKit.MimeVisitor.VisitMimePart.

ComputeContentMd5 ( ) : string

Computes the MD5 checksum of the content.

Computes the MD5 checksum of the MIME content in its canonical format and then base64-encodes the result.

GetBestEncoding ( EncodingConstraint constraint, CancellationToken cancellationToken = default(CancellationToken) ) : ContentEncoding

Calculates the most efficient content encoding given the specified constraint.

If no ContentObject is set, ContentEncoding.SevenBit will be returned.

GetBestEncoding ( EncodingConstraint constraint, int maxLineLength, CancellationToken cancellationToken = default(CancellationToken) ) : ContentEncoding

Calculates the most efficient content encoding given the specified constraint.

If no ContentObject is set, ContentEncoding.SevenBit will be returned.

MimePart ( ) : System

Initializes a new instance of the MimeKit.MimePart class with the default Content-Type of application/octet-stream.

Creates a new MimePart with a Content-Type of application/octet-stream.

MimePart ( MimeKit.ContentType contentType ) : System

Initializes a new instance of the MimeKit.MimePart class with the specified content type.

Creates a new MimePart with the specified Content-Type value.

MimePart ( MimeKit.MimeEntityConstructorArgs args ) : System

Initializes a new instance of the MimeKit.MimePart class based on the MimeEntityConstructorArgs.

This constructor is used by MimeKit.MimeParser.

MimePart ( string contentType ) : System

Initializes a new instance of the MimeKit.MimePart class with the specified content type.

Creates a new MimePart with the specified Content-Type value.

MimePart ( string mediaType, string mediaSubtype ) : System

Initializes a new instance of the MimeKit.MimePart class with the specified media type and subtype.

Creates a new MimePart with the specified media type and subtype.

Prepare ( EncodingConstraint constraint, int maxLineLength = 78 ) : void

Prepare the MIME entity for transport using the specified encoding constraints.

Prepares the MIME entity for transport using the specified encoding constraints.

VerifyContentMd5 ( ) : bool

Verifies the Content-Md5 value against an independently computed md5sum.

Computes the MD5 checksum of the MIME content and compares it with the value in the Content-MD5 header, returning true if and only if the values match.

WriteTo ( MimeKit.FormatOptions options, Stream stream, bool contentOnly, CancellationToken cancellationToken = default(CancellationToken) ) : void

Writes the MimeKit.MimePart to the specified output stream.

Writes the MIME part to the output stream.

Protected Methods

Method Description
OnHeadersChanged ( HeaderListChangedAction action, Header header ) : void

Called when the headers change in some way.

Updates the ContentTransferEncoding, ContentDuration, and ContentMd5 properties if the corresponding headers have changed.

Private Methods

Method Description
IsNullOrWhiteSpace ( string value ) : bool
NeedsEncoding ( ContentEncoding encoding ) : bool

Method Details

Accept() public method

Dispatches to the specific visit method for this MIME entity.
This default implementation for MimeKit.MimePart nodes calls MimeKit.MimeVisitor.VisitMimePart. Override this method to call into a more specific method on a derived visitor class of the MimeKit.MimeVisitor class. However, it should still support unknown visitors by calling MimeKit.MimeVisitor.VisitMimePart.
/// is null. ///
public Accept ( MimeKit.MimeVisitor visitor ) : void
visitor MimeKit.MimeVisitor The visitor.
return void

ComputeContentMd5() public method

Computes the MD5 checksum of the content.
Computes the MD5 checksum of the MIME content in its canonical format and then base64-encodes the result.
/// The is null. ///
public ComputeContentMd5 ( ) : string
return string

GetBestEncoding() public method

Calculates the most efficient content encoding given the specified constraint.
If no ContentObject is set, ContentEncoding.SevenBit will be returned.
/// is not a valid value. /// /// The operation was canceled via the cancellation token. /// /// An I/O error occurred. ///
public GetBestEncoding ( EncodingConstraint constraint, CancellationToken cancellationToken = default(CancellationToken) ) : ContentEncoding
constraint EncodingConstraint The encoding constraint.
cancellationToken System.Threading.CancellationToken A cancellation token.
return ContentEncoding

GetBestEncoding() public method

Calculates the most efficient content encoding given the specified constraint.
If no ContentObject is set, ContentEncoding.SevenBit will be returned.
/// is not between 72 and 998 (inclusive). /// -or- /// is not a valid value. /// /// The operation was canceled via the cancellation token. /// /// An I/O error occurred. ///
public GetBestEncoding ( EncodingConstraint constraint, int maxLineLength, CancellationToken cancellationToken = default(CancellationToken) ) : ContentEncoding
constraint EncodingConstraint The encoding constraint.
maxLineLength int The maximum allowable length for a line (not counting the CRLF). Must be between 72 and 998 (inclusive).
cancellationToken System.Threading.CancellationToken A cancellation token.
return ContentEncoding

MimePart() public method

Initializes a new instance of the MimeKit.MimePart class with the default Content-Type of application/octet-stream.
Creates a new MimePart with a Content-Type of application/octet-stream.
public MimePart ( ) : System
return System

MimePart() public method

Initializes a new instance of the MimeKit.MimePart class with the specified content type.
Creates a new MimePart with the specified Content-Type value.
/// is null. ///
public MimePart ( MimeKit.ContentType contentType ) : System
contentType MimeKit.ContentType The content type.
return System

MimePart() public method

Initializes a new instance of the MimeKit.MimePart class based on the MimeEntityConstructorArgs.
This constructor is used by MimeKit.MimeParser.
/// is null. ///
public MimePart ( MimeKit.MimeEntityConstructorArgs args ) : System
args MimeKit.MimeEntityConstructorArgs Information used by the constructor.
return System

MimePart() public method

Initializes a new instance of the MimeKit.MimePart class with the specified content type.
Creates a new MimePart with the specified Content-Type value.
/// is null. /// /// could not be parsed. ///
public MimePart ( string contentType ) : System
contentType string The content type.
return System

MimePart() public method

Initializes a new instance of the MimeKit.MimePart class with the specified media type and subtype.
Creates a new MimePart with the specified media type and subtype.
/// is null. /// -or- /// is null. /// -or- /// is null. /// /// contains more than one or /// . /// -or- /// contains one or more arguments of an unknown type. ///
public MimePart ( string mediaType, string mediaSubtype ) : System
mediaType string The media type.
mediaSubtype string The media subtype.
return System

OnHeadersChanged() protected method

Called when the headers change in some way.
Updates the ContentTransferEncoding, ContentDuration, and ContentMd5 properties if the corresponding headers have changed.
protected OnHeadersChanged ( HeaderListChangedAction action, Header header ) : void
action HeaderListChangedAction The type of change.
header Header The header being added, changed or removed.
return void

Prepare() public method

Prepare the MIME entity for transport using the specified encoding constraints.
Prepares the MIME entity for transport using the specified encoding constraints.
/// is not between 60 and 998 (inclusive). /// -or- /// is not a valid value. ///
public Prepare ( EncodingConstraint constraint, int maxLineLength = 78 ) : void
constraint EncodingConstraint The encoding constraint.
maxLineLength int The maximum number of octets allowed per line (not counting the CRLF). Must be between 60 and 998 (inclusive).
return void

VerifyContentMd5() public method

Verifies the Content-Md5 value against an independently computed md5sum.
Computes the MD5 checksum of the MIME content and compares it with the value in the Content-MD5 header, returning true if and only if the values match.
public VerifyContentMd5 ( ) : bool
return bool

WriteTo() public method

Writes the MimeKit.MimePart to the specified output stream.
Writes the MIME part to the output stream.
/// is null. /// -or- /// is null. /// /// The operation was canceled via the cancellation token. /// /// An I/O error occurred. ///
public WriteTo ( MimeKit.FormatOptions options, Stream stream, bool contentOnly, CancellationToken cancellationToken = default(CancellationToken) ) : void
options MimeKit.FormatOptions The formatting options.
stream Stream The output stream.
contentOnly bool true if only the content should be written; otherwise, false.
cancellationToken System.Threading.CancellationToken A cancellation token.
return void