Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
|
Decode Base64 MIME BodyDecoding 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.