SQL Server Stored Procedure Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

SQL Server
Stored Procedure Examples

Quick Start
Encryption
File Access
IMAP
POP3
SMTP
Email Object
FTP
HTML-to-XML
HTTP
MHT
MIME
RSA Encryption
Socket
Spider
String
Tar
Upload
XML
XMP
Zip

Byte Array
RSS
Atom
Self-Extractor

Save HTML Email Embedded Images

Saves HTML embedded items to files in a subdirectory. Images, style sheets, and anything else embedded within HTML, are not considered to be attachments. Instead, these items are "related items". The Chilkat email object provides a set of methods/properties for accessing the related items within an email.

Download Chilkat Email ActiveX for POP3 / SMTP

Download Chilkat IMAP ActiveX

CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @iTmp0 int
    DECLARE @sTmp0 nvarchar(4000)
    --  Create a MailMan or Imap object first for the purpose
    --  of unlocking the component. (Only one is necessary)
    DECLARE @mailman int
    EXEC @hr = sp_OACreate 'Chilkat.MailMan2', @mailman OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    EXEC sp_OAMethod @mailman, 'UnlockComponent', NULL, 'anything for 30-day trial'
    DECLARE @imap int
    EXEC @hr = sp_OACreate 'Chilkat.Imap', @imap OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    EXEC sp_OAMethod @imap, 'UnlockComponent', NULL, 'anything for 30-day trial'

    DECLARE @email int
    EXEC @hr = sp_OACreate 'Chilkat.Email2', @email OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    --  Load an email object containing HTML with embedded images.
    --  This .eml can be downloaded from:
    --  http://www.example-code.com/testData/HtmlEmail.eml
    DECLARE @success int

    EXEC sp_OAMethod @email, 'LoadEml', @success OUT, 'HtmlEmail.eml'
    IF @success <> 1
      BEGIN
        EXEC sp_OAGetProperty @email, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        RETURN
      END

    --  Iterate over the related items.
    --  Print the file name and save each to a file.
    DECLARE @i int

    EXEC sp_OAGetProperty @email, 'NumRelatedItems', @iTmp0 OUT
    SELECT @i = 0
    WHILE @i <= @iTmp0 - 1
      BEGIN

        EXEC sp_OAMethod @email, 'GetRelatedFilename', @sTmp0 OUT, @i
        PRINT @sTmp0

        EXEC sp_OAMethod @email, 'SaveRelatedItem', @success OUT, @i, 'myRelatedItems'
        IF @success <> 1
          BEGIN
            EXEC sp_OAGetProperty @email, 'LastErrorText', @sTmp0 OUT
            PRINT @sTmp0
            RETURN
          END
        SELECT @i = @i + 1
      END
END
GO

 

Need a specific example? Send a request to support@chilkatsoft.com

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