Click or drag to resize
MimeKit

MimeContent Class

Encapsulates a content stream used by MimePart.
Inheritance Hierarchy

Namespace:  MimeKit
Assembly:  MimeKit (in MimeKit.dll) Version: 2.14.0
Syntax
C#
public class MimeContent : IMimeContent

The MimeContent type exposes the following members.

Constructors
  NameDescription
Public methodMimeContent
Initialize a new instance of the MimeContent class.
Top
Properties
  NameDescription
Public propertyEncoding
Get or set the content encoding.
Public propertyNewLineFormat
Get the new-line format, if known.
Public propertyStream
Get the content stream.
Top
Methods
  NameDescription
Public methodCode exampleDecodeTo
Decode the content stream into another stream.
Public methodCode exampleDecodeToAsync
Asynchronously decode the content stream into another stream.
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 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.)
Public methodOpen
Open the decoded content stream.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodWriteTo
Copy the content stream to the specified output stream.
Public methodWriteToAsync
Asynchronously copy the content stream to the specified output stream.
Top
Remarks
A MimeContent represents the content of a MimePart. The content has both a stream and an encoding (typically Default).
Examples
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