SQL Server
SQL Server
Check if a MIME Entity is Encrypted (S/MIME)
See more MIME Examples
Demonstrates the Chilkat Mime.IsEncrypted method, which returns whether the entity is a CMS/PKCS #7 encrypted S/MIME wrapper. It takes no arguments.
Note: The file path is relative to the application's current working directory. Absolute paths may also be used. Supply the path to your own file.
Background: This tells you a message is encrypted and must be decrypted before its real content is available — the trigger for supplying a recipient certificate and private key to
Decrypt. Reading the body without decrypting first would just yield the opaque PKCS #7 blob.Chilkat SQL Server Downloads
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @iTmp0 int
DECLARE @sTmp0 nvarchar(4000)
DECLARE @success int
SELECT @success = 0
-- Demonstrates the Mime.IsEncrypted method, which returns whether the entity is a CMS/PKCS #7 encrypted S/MIME wrapper. It takes no arguments.
DECLARE @mime int
EXEC @hr = sp_OACreate 'Chilkat.Mime', @mime OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
EXEC sp_OAMethod @mime, 'LoadMimeFile', @success OUT, 'qa_data/encrypted.eml'
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @mime, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @mime
RETURN
END
EXEC sp_OAMethod @mime, 'IsEncrypted', @iTmp0 OUT
IF @iTmp0
BEGIN
PRINT 'This is an encrypted S/MIME message.'
END
ELSE
BEGIN
PRINT 'This is not an encrypted S/MIME message.'
END
EXEC @hr = sp_OADestroy @mime
END
GO