Click or drag to resize
MimeKit

IMimePart Interface

An interface for a leaf-node MIME part that contains content such as the message body text or an attachment.

Namespace: MimeKit
Assembly: MimeKit (in MimeKit.dll) Version: 4.7.1
Syntax
C#
public interface IMimePart : IMimeEntity, 
	IDisposable

The IMimePart type exposes the following members.

Properties
 NameDescription
Public propertyCode exampleContent Get or set the MIME content.
Public propertyContentBase Get or set the base content URI.
(Inherited from IMimeEntity)
Public propertyContentDescription Get or set the description of the content if available.
Public propertyContentDisposition Get or set the content disposition.
(Inherited from IMimeEntity)
Public propertyContentDuration Get or set the duration of the content if available.
Public propertyContentId Get or set the Content-Id.
(Inherited from IMimeEntity)
Public propertyContentLocation Get or set the content location.
(Inherited from IMimeEntity)
Public propertyContentMd5 Get or set the md5sum of the content.
Public propertyContentTransferEncoding Get or set the content transfer encoding.
Public propertyContentType Get the type of the content.
(Inherited from IMimeEntity)
Public propertyCode exampleFileName Get or set the name of the file.
Public propertyHeaders Get the list of headers.
(Inherited from IMimeEntity)
Public propertyIsAttachment Get a value indicating whether this entity is an attachment.
(Inherited from IMimeEntity)
Top
Methods
 NameDescription
Public methodAccept Dispatches to the specific visit method for this MIME entity.
(Inherited from IMimeEntity)
Public methodComputeContentMd5 Compute the MD5 checksum of the content.
Public methodDispose
(Inherited from IDisposable)
Public methodGetBestEncoding(EncodingConstraint, CancellationToken) Calculate the most efficient content encoding given the specified constraint.
Public methodGetBestEncoding(EncodingConstraint, Int32, CancellationToken) Calculate the most efficient content encoding given the specified constraint.
Public methodPrepare Prepare the MIME entity for transport using the specified encoding constraints.
(Inherited from IMimeEntity)
Public methodVerifyContentMd5 Verify the Content-Md5 value against an independently computed md5sum.
Public methodWriteTo(Stream, CancellationToken) Write the IMimeEntity to the specified output stream.
(Inherited from IMimeEntity)
Public methodWriteTo(String, CancellationToken) Write the IMimeEntity to the specified file.
(Inherited from IMimeEntity)
Public methodWriteTo(FormatOptions, Stream, CancellationToken) Write the IMimeEntity to the specified output stream.
(Inherited from IMimeEntity)
Public methodWriteTo(FormatOptions, String, CancellationToken) Write the IMimeEntity to the specified file.
(Inherited from IMimeEntity)
Public methodWriteTo(Stream, Boolean, CancellationToken) Write the IMimeEntity to the specified output stream.
(Inherited from IMimeEntity)
Public methodWriteTo(String, Boolean, CancellationToken) Write the IMimeEntity to the specified file.
(Inherited from IMimeEntity)
Public methodWriteTo(FormatOptions, Stream, Boolean, CancellationToken) Write the IMimeEntity to the specified output stream.
(Inherited from IMimeEntity)
Public methodWriteTo(FormatOptions, String, Boolean, CancellationToken) Write the IMimeEntity to the specified file.
(Inherited from IMimeEntity)
Public methodWriteToAsync(Stream, CancellationToken) Asynchronously write the IMimeEntity to the specified output stream.
(Inherited from IMimeEntity)
Public methodWriteToAsync(String, CancellationToken) Asynchronously write the IMimeEntity to the specified file.
(Inherited from IMimeEntity)
Public methodWriteToAsync(FormatOptions, Stream, CancellationToken) Asynchronously write the IMimeEntity to the specified output stream.
(Inherited from IMimeEntity)
Public methodWriteToAsync(FormatOptions, String, CancellationToken) Asynchronously write the IMimeEntity to the specified file.
(Inherited from IMimeEntity)
Public methodWriteToAsync(Stream, Boolean, CancellationToken) Asynchronously write the IMimeEntity to the specified output stream.
(Inherited from IMimeEntity)
Public methodWriteToAsync(String, Boolean, CancellationToken) Asynchronously write the IMimeEntity to the specified file.
(Inherited from IMimeEntity)
Public methodWriteToAsync(FormatOptions, Stream, Boolean, CancellationToken) Asynchronously write the IMimeEntity to the specified output stream.
(Inherited from IMimeEntity)
Public methodWriteToAsync(FormatOptions, String, Boolean, CancellationToken) Asynchronously write the IMimeEntity to the specified file.
(Inherited from IMimeEntity)
Top
Remarks
A leaf-node MIME part that contains content such as the message body text or an attachment.
Example
C#
foreach (var attachment in message.Attachments) {
    if (attachment is MessagePart) {
        var fileName = attachment.ContentDisposition?.FileName;
        var rfc822 = (MessagePart) attachment;

        if (string.IsNullOrEmpty (fileName))
            fileName = "attached-message.eml";

        using (var stream = File.Create (fileName))
            rfc822.Message.WriteTo (stream);
    } else {
        var part = (MimePart) attachment;
        var fileName = part.FileName;

        using (var stream = File.Create (fileName))
            part.Content.DecodeTo (stream);
    }
}
See Also