Click or drag to resize
MimeKit

MimeParser(Stream, MimeFormat, Boolean) Constructor

Initialize a new instance of the MimeParser class.

Namespace: MimeKit
Assembly: MimeKit (in MimeKit.dll) Version: 4.7.1
Syntax
C#
public MimeParser(
	Stream stream,
	MimeFormat format,
	bool persistent = false
)

Parameters

stream  Stream
The stream to parse.
format  MimeFormat
The format of the stream.
persistent  Boolean  (Optional)
true if the stream is persistent; otherwise false.
Exceptions
ExceptionCondition
ArgumentNullExceptionstream is null.
Remarks

Creates a new MimeParser that will parse the specified stream.

If persistent is true and stream is seekable, then the MimeParser will not copy the content of MimeParts into memory. Instead, it will use a BoundStream to reference a substream of stream. This has the potential to not only save memory usage, but also improve MimeParser performance.

It should be noted, however, that disposing stream will make it impossible for MimeContent to read the content.

Example
C#
public static MimeMessage ParseMessage (string fileName)
{
    // Load a MimeMessage from a file path or stream
    using (var stream = File.OpenRead (fileName)) {
        var parser = new MimeParser (stream, MimeFormat.Entity);

        return parser.ParseMessage ();
    }
}
See Also