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
|
Create EDIFACT MIMECreate 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.