SQL Server Stored Procedure Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

SQL Server
Stored Procedure Examples

Quick Start
Encryption
File Access
IMAP
POP3
SMTP
Email Object
DKIM / DomainKey
FTP
HTML Conversion
HTTP
MHT
MIME
NTLM
RSA
Diffie-Hellman
DSA
Socket
Spider
SSH Key
SSH
SSH Tunnel
SFTP
String
Tar
Upload
XML
XMP
Zip

Amazon S3
Bz2
CSV
FileAccess
Byte Array
RSS
Atom
Self-Extractor

Decode Base64 MIME Body

Decoding a MIME body from Base64.

CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @mime int
    EXEC @hr = sp_OACreate 'Chilkat.Mime', @mime OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    DECLARE @success int

    EXEC sp_OAMethod @mime, 'UnlockComponent', @success OUT, 'Anything for 30-day trial'
    IF @success = 0
      BEGIN
        PRINT 'Failed to unlock component'
        RETURN
      END

    --  Create MIME with base64 encoding:
    EXEC sp_OAMethod @mime, 'SetBodyFromPlainText', NULL, 'This is a test'
    EXEC sp_OASetProperty @mime, 'Charset', 'windows-1252'
    EXEC sp_OASetProperty @mime, 'Encoding', 'base64'

    DECLARE @mimeStr1 nvarchar(4000)

    EXEC sp_OAMethod @mime, 'GetMime', @mimeStr1 OUT


    PRINT @mimeStr1

    PRINT '-------------------------------'

    --  Output looks like this:
    --  Content-Type: text/plain;
    --           charset="windows-1252"
    --  content-transfer-encoding: base64
    -- 
    --  VGhpcyBpcyBhIHRlc3Q=

    --  Load the MIME into another Chilkat MIME object:
    DECLARE @mime2 int
    EXEC @hr = sp_OACreate 'Chilkat.Mime', @mime2 OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    EXEC sp_OAMethod @mime2, 'LoadMime', NULL, @mimeStr1

    --  Get the MIME body decoded:
    DECLARE @decodedBody nvarchar(4000)

    EXEC sp_OAMethod @mime2, 'GetBodyDecoded', @decodedBody OUT

    --  Prints: this is a test

    PRINT @decodedBody


END
GO

 

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