Mime Message ExtensionsSign(Mime Message, Cryptography Context, Digest Algorithm, Cancellation Token) Method
Sign the message using the specified cryptography context and digest algorithm.
Definition
Namespace: MimeKit.Cryptography
Assembly: MimeKit.Cryptography (in MimeKit.Cryptography.dll) Version: 5.0.0
Assembly: MimeKit.Cryptography (in MimeKit.Cryptography.dll) Version: 5.0.0
C#
public static void Sign(
this MimeMessage message,
CryptographyContext ctx,
DigestAlgorithm digestAlgo,
CancellationToken cancellationToken = default
)Parameters
- message MimeMessage
- The message to sign.
- ctx CryptographyContext
- The cryptography context.
- digestAlgo DigestAlgorithm
- The digest algorithm.
- cancellationToken CancellationToken (Optional)
- The cancellation token.
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. |
| ArgumentOutOfRangeException | The digestAlgo was out of range. |
| NotSupportedException | The digestAlgo is not supported. |
| 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. |