Click or drag to resize
MimeKit

MimePart Class

A leaf-node MIME part that contains content such as the message body text or an attachment.
Inheritance Hierarchy

Namespace:  MimeKit
Assembly:  MimeKit (in MimeKit.dll) Version: 2.0.7.0
Syntax
C#
public class MimePart : MimeEntity

The MimePart type exposes the following members.

Constructors
  NameDescription
Public methodMimePart
Initializes a new instance of the MimePart class with the default Content-Type of application/octet-stream.
Public methodMimePart(String)
Initializes a new instance of the MimePart class with the specified content type.
Public methodMimePart(ContentType)
Initializes a new instance of the MimePart class with the specified content type.
Public methodMimePart(MimeEntityConstructorArgs)
Initializes a new instance of the MimePart class based on the MimeEntityConstructorArgs.
Public methodMimePart(String, String)
Initializes a new instance of the MimePart class with the specified media type and subtype.
Public methodMimePart(String, String, Object)
Initializes a new instance of the MimePart class with the specified media type and subtype.
Top
Properties
  NameDescription
Public propertyCode exampleContent
Gets or sets the MIME content.
Public propertyContentBase
Gets or sets the base content URI.
(Inherited from MimeEntity.)
Public propertyContentDisposition
Gets or sets the content disposition.
(Inherited from MimeEntity.)
Public propertyContentDuration
Gets or sets the duration of the content if available.
Public propertyContentId
Gets or sets the content identifier.
(Inherited from MimeEntity.)
Public propertyContentLocation
Gets or sets the content location.
(Inherited from MimeEntity.)
Public propertyContentMd5
Gets or sets the md5sum of the content.
Public propertyContentObject Obsolete.
Gets or sets the MIME content.
Public propertyContentTransferEncoding
Gets or sets the content transfer encoding.
Public propertyContentType
Gets the type of the content.
(Inherited from MimeEntity.)
Public propertyCode exampleFileName
Gets or sets the name of the file.
Public propertyHeaders
Gets the list of headers.
(Inherited from MimeEntity.)
Public propertyIsAttachment
Gets a value indicating whether this MimePart is an attachment.
(Inherited from MimeEntity.)
Top
Methods
  NameDescription
Public methodAccept
Dispatches to the specific visit method for this MIME entity.
(Overrides MimeEntityAccept(MimeVisitor).)
Public methodComputeContentMd5
Computes the MD5 checksum of the content.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetBestEncoding(EncodingConstraint, CancellationToken)
Calculates the most efficient content encoding given the specified constraint.
Public methodGetBestEncoding(EncodingConstraint, Int32, CancellationToken)
Calculates the most efficient content encoding given the specified constraint.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodOnHeadersChanged
Called when the headers change in some way.
(Overrides MimeEntityOnHeadersChanged(HeaderListChangedAction, Header).)
Public methodPrepare
Prepare the MIME entity for transport using the specified encoding constraints.
(Overrides MimeEntityPrepare(EncodingConstraint, Int32).)
Protected methodRemoveHeader
Removes the header.
(Inherited from MimeEntity.)
Protected methodSetHeader(String, Byte)
Sets the header using the raw value.
(Inherited from MimeEntity.)
Protected methodSetHeader(String, String)
Sets the header.
(Inherited from MimeEntity.)
Public methodToString
Returns a String that represents the current MimeEntity.
(Inherited from MimeEntity.)
Protected methodTryInit
Tries to use the given object to initialize the appropriate property.
(Inherited from MimeEntity.)
Public methodVerifyContentMd5
Verifies the Content-Md5 value against an independently computed md5sum.
Public methodWriteTo(Stream, CancellationToken)
Write the MimeEntity to the specified output stream.
(Inherited from MimeEntity.)
Public methodWriteTo(String, CancellationToken)
Writes the MimeEntity to the specified file.
(Inherited from MimeEntity.)
Public methodWriteTo(Stream, Boolean, CancellationToken)
Write the MimeEntity to the specified output stream.
(Inherited from MimeEntity.)
Public methodWriteTo(String, Boolean, CancellationToken)
Write the MimeEntity to the specified file.
(Inherited from MimeEntity.)
Public methodWriteTo(FormatOptions, Stream, CancellationToken)
Write the MimeEntity to the specified output stream.
(Inherited from MimeEntity.)
Public methodWriteTo(FormatOptions, String, CancellationToken)
Write the MimeEntity to the specified file.
(Inherited from MimeEntity.)
Public methodWriteTo(FormatOptions, String, Boolean, CancellationToken)
Write the MimeEntity to the specified file.
(Inherited from MimeEntity.)
Public methodWriteTo(FormatOptions, Stream, Boolean, CancellationToken)
Writes the MimePart to the specified output stream.
(Overrides MimeEntityWriteTo(FormatOptions, Stream, Boolean, CancellationToken).)
Public methodWriteToAsync(Stream, CancellationToken)
Asynchronously write the MimeEntity to the specified output stream.
(Inherited from MimeEntity.)
Public methodWriteToAsync(String, CancellationToken)
Asynchronously writes the MimeEntity to the specified file.
(Inherited from MimeEntity.)
Public methodWriteToAsync(Stream, Boolean, CancellationToken)
Adsynchronously write the MimeEntity to the specified output stream.
(Inherited from MimeEntity.)
Public methodWriteToAsync(String, Boolean, CancellationToken)
Asynchronously write the MimeEntity to the specified file.
(Inherited from MimeEntity.)
Public methodWriteToAsync(FormatOptions, Stream, CancellationToken)
Asynchronously write the MimeEntity to the specified output stream.
(Inherited from MimeEntity.)
Public methodWriteToAsync(FormatOptions, String, CancellationToken)
Asynchronously write the MimeEntity to the specified file.
(Inherited from MimeEntity.)
Public methodWriteToAsync(FormatOptions, String, Boolean, CancellationToken)
Asynchronously write the MimeEntity to the specified file.
(Inherited from MimeEntity.)
Public methodWriteToAsync(FormatOptions, Stream, Boolean, CancellationToken)
Asynchronously writes the MimePart to the specified output stream.
(Overrides MimeEntityWriteToAsync(FormatOptions, Stream, Boolean, CancellationToken).)
Top
Remarks
A leaf-node MIME part that contains content such as the message body text or an attachment.
Examples
C#
foreach (var attachment in message.Attachments) {
    if (attachment is MessagePart) {
        var fileName = attachment.ContentDisposition?.FileName :
            (attachment.ContentType.Name ?? "attached.eml");
        var rfc822 = (MessagePart) attachment;

        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
Inheritance Hierarchy