Attachment CollectionAdd(String, Stream, Cancellation Token) Method
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 MimeEntity Add(
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
MimeEntityThe newly added attachment MimeEntity.
Remarks
Adds the stream as an attachment, using the specified file name for deducing the mime-type by extension and for setting the Content-Location.
Exceptions
| ArgumentNullException |
fileName is . -or- stream is . |
| ArgumentException | The specified file path is empty. |
| IOException | An I/O error occurred. |
| OperationCanceledException | The operation was canceled via the cancellation token. |