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

Create EDIFACT MIME

Create an EDIFACT MIME message.

CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @sTmp0 nvarchar(4000)

    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'
        RETURN
      END

    --  Assuming  you have an EDIFACT document loaded into
    --  a string variable, set the MIME body with it:
    DECLARE @ediBody nvarchar(4000)

    SELECT @ediBody = 'UNB+IATB:1+6XPPC+LHPPC+940101:0950+1'' ...'
    EXEC sp_OAMethod @mime, 'SetBodyFromPlainText', NULL, @ediBody

    --  The call to SetBodyFromPlainText automatically set the
    --  content-type to "text/plain".
    --  However, we want:  application/EDIFACT; name=om080923.edi
    EXEC sp_OASetProperty @mime, 'ContentType', 'application/EDIFACT'
    EXEC sp_OASetProperty @mime, 'Name', 'om080923.edi'

    --  We want the content-disposition to be:
    --  Content-Disposition: attachment; filename="om080923.edi"
    EXEC sp_OASetProperty @mime, 'Disposition', 'attachment'
    EXEC sp_OASetProperty @mime, 'Filename', 'om080923.edi'

    --  Make sure the content-transfer-encoding is 7bit:
    --  Content-Transfer-Encoding: 7bit
    EXEC sp_OASetProperty @mime, 'Encoding', '7bit'

    --  Note: MIME header fields are case insensitive.

    --  Add a few other header fields:
    EXEC sp_OAMethod @mime, 'AddHeaderField', NULL, 'Message-ID', '<CHILKAT-MID-83cf2fbf-10cb-4322-ad79-4c1097fd56f2@Matt>'
    EXEC sp_OAMethod @mime, 'AddHeaderField', NULL, 'From', 'support@chilkatsoft.com'
    EXEC sp_OAMethod @mime, 'AddHeaderField', NULL, 'To', 'admin@chilkatsoft.com'
    EXEC sp_OAMethod @mime, 'AddHeaderField', NULL, 'Subject', 'This is a test'
    EXEC sp_OAMethod @mime, 'AddHeaderField', NULL, 'MIME-VERSION', '1.0'
    EXEC sp_OAMethod @mime, 'AddHeaderField', NULL, 'Date', 'Tue, 23 Sep 2008 07:26:39'

    --  Display the complete MIME:
    EXEC sp_OAMethod @mime, 'GetMime', @sTmp0 OUT
    PRINT @sTmp0


END
GO

 

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