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

Access Attached Message (Embedded Email)

How to access an email embedded within another email (i.e. an attached message).

Download Chilkat Email ActiveX for POP3 / SMTP

Download Chilkat IMAP ActiveX

CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @sTmp0 nvarchar(4000)
    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 from a .eml
    DECLARE @success int

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

    --  Display how many attached emails are embedded within
    --  this one:
    DECLARE @numAttached int

    EXEC sp_OAGetProperty @email, 'NumAttachedMessages', @numAttached OUT

    PRINT @numAttached

    --  Get the 1st attached message.
    DECLARE @email2 int

    EXEC sp_OAMethod @email, 'GetAttachedMessage', @email2 OUT, 0
    IF Not (@email2 Is NULL )
      BEGIN

        --  Display the subject, From, and a header field...
        EXEC sp_OAGetProperty @email2, 'Subject', @sTmp0 OUT

        PRINT @sTmp0
        EXEC sp_OAGetProperty @email2, 'From', @sTmp0 OUT

        PRINT @sTmp0
        EXEC sp_OAMethod @email2, 'GetHeaderField', @sTmp0 OUT, 'X-SOMETHING'
        PRINT @sTmp0
      END


END
GO

 

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