Click or drag to resize
MimeKit

IMimeContent Interface

An interface for content stream encapsulation as used by MimePart.

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

The IMimeContent type exposes the following members.

Properties
 NameDescription
Public propertyEncoding Get 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 methodDispose
(Inherited from IDisposable)
Public methodOpen Open the decoded content stream.
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
Implemented by MimeContent.
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