Click or drag to resize
MimeKit

MimeContentWriteToAsync Method

Asynchronously copy the content stream to the specified output stream.

Namespace: MimeKit
Assembly: MimeKit (in MimeKit.dll) Version: 4.3.0
Syntax
C#
public Task WriteToAsync(
	Stream stream,
	CancellationToken cancellationToken = default
)

Parameters

stream  Stream
The output stream.
cancellationToken  CancellationToken  (Optional)
The cancellation token.

Return Value

Task
An awaitable task.

Implements

IMimeContentWriteToAsync(Stream, CancellationToken)
Exceptions
ExceptionCondition
ArgumentNullExceptionstream is null.
ObjectDisposedException The MimeContent has been disposed.
OperationCanceledException The operation was canceled via the cancellation token.
IOException An I/O error occurred.
Remarks

This is equivalent to simply using CopyTo(Stream) to copy the content stream to the output stream except that this method is cancellable.

Note  Note
If you want the decoded content, use DecodeTo(Stream, CancellationToken) instead.
See Also