Sample code for 30+ languages & platforms
SQL Server

Check if a MIME Tree Contains Signed Parts

See more MIME Examples

Demonstrates the Chilkat Mime.ContainsSignedParts method, which returns whether the currently visible MIME tree contains a complete detached or opaque CMS/PKCS #7 signed entity. 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: Where IsSigned asks whether the top entity is a signature wrapper, this scans the whole tree for a signed part nested anywhere inside — useful when signing is applied to a sub-part rather than the outermost entity. It is the discovery step before deciding whether verification is needed.

Chilkat SQL Server Downloads

SQL Server
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @iTmp0 int
    DECLARE @sTmp0 nvarchar(4000)
    DECLARE @success int
    SELECT @success = 0

    --  Demonstrates the Mime.ContainsSignedParts method, which returns whether the MIME tree contains a complete CMS/PKCS #7 signed entity.  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/message.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, 'ContainsSignedParts', @iTmp0 OUT
    IF @iTmp0
      BEGIN

        PRINT 'The message tree contains a signed part.'
      END
    ELSE
      BEGIN

        PRINT 'The message tree contains no signed part.'
      END

    EXEC @hr = sp_OADestroy @mime


END
GO