Attachment CollectionAdd Async(String, Cancellation Token) Method
Asynchronously add an attachment.
Definition
Namespace: MimeKit
Assembly: MimeKit.Core (in MimeKit.Core.dll) Version: 5.0.0
The newly added attachment MimeEntity.
Assembly: MimeKit.Core (in MimeKit.Core.dll) Version: 5.0.0
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
TaskMimeEntityThe newly added attachment MimeEntity.
Remarks
Asynchronously adds the specified file as an attachment.
Exceptions
| ArgumentNullException | fileName is . |
| ArgumentException | fileName is a zero-length string, contains only white space, or contains one or more invalid characters. |
| DirectoryNotFoundException | fileName 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. |