LegacyMimeParser(Stream, MimeFormat, Boolean) Constructor

Initialize a new instance of the LegacyMimeParser class.

Definition

Namespace: MimeKit
Assembly: MimeKit.Core (in MimeKit.Core.dll) Version: 5.0.0
C#
public LegacyMimeParser(
	Stream stream,
	MimeFormat format,
	bool persistent = false
)

Parameters

stream  Stream
The stream to parse.
format  MimeFormat
The format of the stream.
persistent  Boolean  (Optional)
if the stream is persistent; otherwise, .

Remarks

Creates a new LegacyMimeParser that will parse the specified stream.

If persistent is and stream is seekable, then the LegacyMimeParser will not copy the content of MimeParts into memory. Instead, it will use a BoundedStream to reference a substream of stream. This has the potential to not only save memory usage, but also improve LegacyMimeParser 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 ();
    }
}
                  

Exceptions

ArgumentNullException stream is .

See Also