Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicPythonRubySQL ServerSwiftTclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcel

SQL Server Examples


ASN.1
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Service Bus
Bounced Email
Box
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
ECC
Email Object
Encryption
FTP
Facebook
Firebase
GeoOp
Google APIs
Google Calendar
Google Cloud Storage
Google Drive
Gzip
HTML-to-XML/Text
HTTP
HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)

Java KeyStore (JKS)
MHT / HTML Email
MIME
Microsoft Graph
NTLM
OAuth1
OAuth2
OneDrive
OpenSSL
Outlook
PEM
PFX/P12
POP3
PRNG
PayPal
Peoplevox
QuickBooks
REST
RSA Encryption
SCP
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
SharePoint
Shopify
Socket/SSL/TLS
Spider
Stream
Stripe
SugarCRM
Tar Archive
Twitter
VoiceBase
Walmart
WebSocket
XML
XML Digital Signatures
XMP
Xero
Zip
curl
eBay

 

 

 

(SQL Server) Generate a Unique Key for an Email

Demonstrates how to generate a unique key for an email.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @sTmp0 nvarchar(4000)
    DECLARE @email int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Email', @email OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    DECLARE @success int
    EXEC sp_OAMethod @email, 'LoadEml', @success OUT, 'qa_data/eml/someEmail.eml'
    IF STR(@success) <> 1
      BEGIN
        EXEC sp_OAGetProperty @email, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @email
        RETURN
      END

    --  The ComputeGlobalKey method computes a global unique key for an email that may be used as a
    --  key for a relational database table (or anything else).
    --  The key is created by a digest-MD5 hash of the concatenation of the following header fields:
    --  Message-ID, Subject, From, Date, To. (The header fields are Q/B decoded if necessary,
    --  converted to the utf-8 encoding, concatenated, and hashed using MD5.)
    --  The 16-byte MD5 hash is returned as an encoded string (such as base64, url, hex, etc.)
    --  If the bFold argument is true, then the 16-byte MD5 hash is folded to 8 bytes with an XOR to produce a shorter key.

    DECLARE @bFold int
    SELECT @bFold = 0
    DECLARE @key nvarchar(4000)
    EXEC sp_OAMethod @email, 'ComputeGlobalKey', @key OUT, 'hex', STR(@bFold)

    PRINT 'key: ' + @key

    EXEC @hr = sp_OADestroy @email


END
GO

 

© 2000-2016 Chilkat Software, Inc. All Rights Reserved.