Click or drag to resize
MimeKit

MimeEntityLoad(ContentType, Stream, CancellationToken) Method

Load a MimeEntity from the specified content stream.

Namespace: MimeKit
Assembly: MimeKit (in MimeKit.dll) Version: 4.7.1
Syntax
C#
public static MimeEntity Load(
	ContentType contentType,
	Stream content,
	CancellationToken cancellationToken = default
)

Parameters

contentType  ContentType
The Content-Type of the stream.
content  Stream
The content stream.
cancellationToken  CancellationToken  (Optional)
The cancellation token.

Return Value

MimeEntity
The parsed MIME entity.
Exceptions
ExceptionCondition
ArgumentNullException

contentType is null.

-or-

content is null.

OperationCanceledException The operation was canceled via the cancellation token.
FormatException There was an error parsing the entity.
IOException An I/O error occurred.
Remarks
This method is mostly meant for use with APIs such as HttpWebResponse where the headers are parsed separately from the content.
Example
C#
MimeEntity ParseMultipartFormData (HttpWebResponse response)
{
    var contentType = ContentType.Parse (response.ContentType);

    return MimeEntity.Load (contentType, response.GetResponseStream ());
}
See Also