Click or drag to resize
MimeKit

AttachmentCollectionAddAsync(String, 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,
	CancellationToken cancellationToken = default
)

Parameters

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

Return Value

TaskMimeEntity
The newly added attachment MimeEntity.
Exceptions
ExceptionCondition
ArgumentNullExceptionfileName is null.
ArgumentExceptionfileName is a zero-length string, contains only white space, or contains one or more invalid characters.
DirectoryNotFoundExceptionfileName is an invalid file path.
FileNotFoundException The specified file path 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.

See Also