Click or drag to resize
MimeKit

AttachmentCollectionAddAsync(String, ContentType, CancellationToken) Method

Asynchronously add an attachment.

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

Parameters

fileName  String
The name of the file.
contentType  ContentType
The mime-type of the file.
cancellationToken  CancellationToken  (Optional)
The cancellation token.

Return Value

TaskMimeEntity
The newly added attachment MimeEntity.
Exceptions
ExceptionCondition
ArgumentNullException

fileName is null.

-or-

contentType is null.

ArgumentException The specified file path is empty.
FileNotFoundException The specified file could not be found.
UnauthorizedAccessException The user does not have access to read the specified file.
IOException An I/O error occurred.
OperationCanceledException The operation was canceled via the cancellation token.
Remarks

Asynchronously adds the specified file as an attachment using the supplied Content-Type.

For a list of known mime-types and their associated file extensions, see http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types

See Also