Mime Message ExtensionsSign Async(Mime Message, Cryptography Context, Cancellation Token) Method
Asynchronously sign the message using the specified cryptography context and the SHA-256 digest algorithm.
Definition
Namespace: MimeKit.Cryptography
Assembly: MimeKit.Cryptography (in MimeKit.Cryptography.dll) Version: 5.0.0
An asynchronous task context.
Assembly: MimeKit.Cryptography (in MimeKit.Cryptography.dll) Version: 5.0.0
C#
public static Task SignAsync(
this MimeMessage message,
CryptographyContext ctx,
CancellationToken cancellationToken = default
)Parameters
- message MimeMessage
- The message to sign.
- ctx CryptographyContext
- The cryptography context.
- cancellationToken CancellationToken (Optional)
- The cancellation token.
Return Value
TaskAn asynchronous task context.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type MimeMessage. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).Remarks
If either of the Resent-Sender or Resent-From headers are set, then the message
will be signed using the Resent-Sender (or first mailbox in the Resent-From)
address as the signer address, otherwise the Sender or From address will be
used instead.
Exceptions
| ArgumentNullException | ctx is . |
| InvalidOperationException |
The message Body has not been set. -or- A sender has not been specified. |
| OperationCanceledException | The operation was canceled via the cancellation token. |
| CertificateNotFoundException | A signing certificate could not be found for the sender. |
| PrivateKeyNotFoundException | The private key could not be found for the sender. |