Click or drag to resize
MimeKit

MultipartEncryptedEncryptAsync(OpenPgpContext, IEnumerableMailboxAddress, MimeEntity, CancellationToken) Method

Asynchronously create a multipart/encrypted MIME part by encrypting the specified entity.

Namespace: MimeKit.Cryptography
Assembly: MimeKit (in MimeKit.dll) Version: 4.3.0
Syntax
C#
public static Task<MultipartEncrypted> EncryptAsync(
	OpenPgpContext ctx,
	IEnumerable<MailboxAddress> recipients,
	MimeEntity entity,
	CancellationToken cancellationToken = default
)

Parameters

ctx  OpenPgpContext
The OpenPGP cryptography context to use for encrypting.
recipients  IEnumerableMailboxAddress
The recipients for the encrypted entity.
entity  MimeEntity
The entity to sign and encrypt.
cancellationToken  CancellationToken  (Optional)
The cancellation token.

Return Value

TaskMultipartEncrypted
A new MultipartEncrypted instance containing the encrypted version of the specified entity.
Exceptions
ExceptionCondition
ArgumentNullException

ctx is null.

-or-

recipients is null.

-or-

entity is null.

ObjectDisposedExceptionentity has been disposed.
OperationCanceledException The operation was canceled via the cancellation token.
PublicKeyNotFoundException A public key for one or more of the recipients could not be found.
Remarks
Encrypts the entity to the specified recipients, encapsulating the result in a new multipart/encrypted part.
See Also