Click or drag to resize
MimeKit

AttachmentCollectionAddAsync(String, Stream, CancellationToken) Method

Asynchronously add an attachment.

Namespace: MimeKit
Assembly: MimeKit (in MimeKit.dll) Version: 4.3.0
Syntax
C#
public Task<MimeEntity> AddAsync(
	string fileName,
	Stream stream,
	CancellationToken cancellationToken = default
)

Parameters

fileName  String
The name of the file.
stream  Stream
The content stream.
cancellationToken  CancellationToken  (Optional)
The cancellation token.

Return Value

TaskMimeEntity
The newly added attachment MimeEntity.
Exceptions
ExceptionCondition
ArgumentNullException

fileName is null.

-or-

stream is null.

ArgumentException The specified file path is empty.
IOException An I/O error occurred.
OperationCanceledException The operation was canceled via the cancellation token.
Remarks

Asynchronously adds the stream as an attachment, using the specified file name for deducing the mime-type by extension and for setting the Content-Location.

See Also