ApplicationPkcs7MimeEncrypt(SecureMimeContext, IEnumerableMailboxAddress, MimeEntity, CancellationToken) Method

Encrypt the specified entity.

Definition

Namespace: MimeKit.Cryptography
Assembly: MimeKit.Cryptography (in MimeKit.Cryptography.dll) Version: 5.0.0
C#
public static ApplicationPkcs7Mime Encrypt(
	SecureMimeContext ctx,
	IEnumerable<MailboxAddress> recipients,
	MimeEntity entity,
	CancellationToken cancellationToken = default
)

Parameters

ctx  SecureMimeContext
The S/MIME context to use for encrypting.
recipients  IEnumerableMailboxAddress
The recipients.
entity  MimeEntity
The entity.
cancellationToken  CancellationToken  (Optional)
The cancellation token.

Return Value

ApplicationPkcs7Mime
The encrypted entity.

Remarks

Encrypts the entity to the specified recipients using the supplied SecureMimeContext.

Exceptions

ArgumentNullException

ctx is .

-or-

recipients is .

-or-

entity is .

ArgumentException Valid certificates could not be found for one or more of the recipients.
ObjectDisposedException entity has been disposed.
OperationCanceledException The operation was canceled via the cancellation token.
CertificateNotFoundException A certificate could not be found for one or more of the recipients.
CmsEnvelopeException An error occurred in the cryptographic message syntax subsystem.

See Also