ITnef PartLoad Tnef Message Async Method
Asynchronously load the TNEF message contained within the part.
Definition
Namespace: MimeKit.Tnef
Assembly: MimeKit.Core (in MimeKit.Core.dll) Version: 5.0.0
The TNEF message.
Assembly: MimeKit.Core (in MimeKit.Core.dll) Version: 5.0.0
C#
Task<TnefMessage> LoadTnefMessageAsync(
TnefOptions? options = null,
CancellationToken cancellationToken = default
)Parameters
- options TnefOptions (Optional)
- The options to use, or to use the default options.
- cancellationToken CancellationToken (Optional)
- The cancellation token.
Return Value
TaskTnefMessageThe TNEF message.
Remarks
Decodes the content of the part and asynchronously loads the TNEF message that it contains.
If options is and the Content-Type of the part has a charset parameter, the codepage of that charset is used as the DefaultCodepage.
The returned message is independent of the part and must be disposed by the caller. Use ConvertToMime(TnefConversionOptions, CancellationToken) to convert it to a MimeMessage.
Example
C#
public static async Task<MimeMessage> ConvertToMimeAsync (TnefPart part, CancellationToken cancellationToken = default)
{
using (var tnef = await part.LoadTnefMessageAsync (null, cancellationToken)) {
// Note: Once the TnefMessage has been loaded, all of its content is in memory, so
// ConvertToMime () does not need an async counterpart.
var result = tnef.ConvertToMime (null, cancellationToken);
return result.Message;
}
}
Exceptions
| ObjectDisposedException | The part has been disposed. |
| InvalidOperationException | The part does not have any content. |
| TnefException | The content does not begin with the TNEF signature. |
| OperationCanceledException | The operation was canceled via the cancellation token. |
| IOException | An I/O error occurred. |