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 Multipart/Alternative MIMECreate a simple multipart/alternative 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 -- Make this a multipart/alternative MIME message: EXEC sp_OAMethod @mime, 'NewMultipartAlternative', NULL -- Create a plain-text part and add it to the multipart/alternative MIME. DECLARE @ptMime int EXEC @hr = sp_OACreate 'Chilkat.Mime', @ptMime OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END EXEC sp_OAMethod @ptMime, 'SetBodyFromPlainText', NULL, 'This is the plain-text body' EXEC sp_OAMethod @mime, 'AppendPart', NULL, @ptMime -- Now do the same for HTML: DECLARE @htMime int EXEC @hr = sp_OACreate 'Chilkat.Mime', @htMime OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END EXEC sp_OAMethod @htMime, 'SetBodyFromHtml', NULL, '<html><body>This is the HTML body</body></html>' EXEC sp_OAMethod @mime, 'AppendPart', NULL, @htMime -- Show the full multipart/alternative MIME text which includes both parts: EXEC sp_OAMethod @mime, 'GetMime', @sTmp0 OUT PRINT @sTmp0 -- Need to change the boundary string? EXEC sp_OASetProperty @mime, 'Boundary', '__NewBoundaryString__123' -- Need to change the charset? EXEC sp_OAMethod @mime, 'GetPart', @ptMime OUT, 0 EXEC sp_OASetProperty @ptMime, 'Charset', 'utf-8' EXEC sp_OAMethod @mime, 'GetPart', @htMime OUT, 1 EXEC sp_OASetProperty @htMime, 'Charset', 'utf-8' -- Need to change the encoding? EXEC sp_OASetProperty @htMime, 'Encoding', 'base64' -- Now show the MIME again: PRINT '---- After Changes ----' EXEC sp_OAMethod @mime, 'GetMime', @sTmp0 OUT PRINT @sTmp0 END GO |
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.