SQL Server
SQL Server
Count the DKIM Signatures in a Message
See more DKIM / DomainKey Examples
Demonstrates the Chilkat Dkim.NumDkimSigs method, which returns the number of DKIM-Signature header fields in a MIME message. The only argument is a BinData holding the complete MIME.
Note: The file paths are relative to the application's current working directory. Absolute paths may also be used. Supply the paths appropriate to your own environment.
Background: A message can legitimately carry several DKIM signatures — the original sender's plus ones added by forwarders or mailing lists — so a verifier needs to know how many there are before checking each. This count is what supplies the valid index range for
DkimVerify. Note that it counts header fields by name only, without validating them, so a malformed DKIM-Signature field is still included in the total.Chilkat SQL Server Downloads
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @sTmp0 nvarchar(4000)
DECLARE @success int
SELECT @success = 0
-- Demonstrates the Dkim.NumDkimSigs method, which returns the number of DKIM-Signature header
-- fields in a MIME message. The only argument is a BinData holding the complete MIME.
DECLARE @dkim int
EXEC @hr = sp_OACreate 'Chilkat.Dkim', @dkim OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
-- Load the complete MIME message.
DECLARE @mimeData int
EXEC @hr = sp_OACreate 'Chilkat.BinData', @mimeData OUT
EXEC sp_OAMethod @mimeData, 'LoadFile', @success OUT, 'qa_data/received.eml'
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @mimeData, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @dkim
EXEC @hr = sp_OADestroy @mimeData
RETURN
END
-- Count the DKIM-Signature header fields. The count includes malformed signatures, since the
-- fields are counted without validating their syntax.
DECLARE @numSigs int
EXEC sp_OAMethod @dkim, 'NumDkimSigs', @numSigs OUT, @mimeData
PRINT 'The message has ' + @numSigs + ' DKIM-Signature header(s).'
EXEC @hr = sp_OADestroy @dkim
EXEC @hr = sp_OADestroy @mimeData
END
GO