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

POP3 Support and Debugging

The mailman object has two properties that provide detailed information about what transpired during a POP3 session. The mailman.LastErrorText property may be examined after any Chilkat method call to get detailed information about the last method called on the object instance. It is standard across all components. The LastErrorText will contain information even when a method is successful. When requesting support, it is almost always beneficial to send the contents of the LastErrorText because it is designed to tell us (Chilkat) what transpired during the method call. In many cases you may easily be able to identify the cause of a problem by looking at LastErrorText.

The Pop3SessionLog property provides a detailed record of the raw command sent to the POP3 server and the raw responses received back from the POP3 server. This is an additional source of information to help understand any POP3 issues. If the information in LastErrorText is not enough, Chilkat support will often ask for the contents of the Pop3SessionLog property.

Note: Just because a property has "Log" in the name does not mean it is a file. The Pop3SessionLog property is a string that contains the actual text of the log.

Download Chilkat Email ActiveX

CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @iTmp0 int
    DECLARE @sTmp0 nvarchar(4000)
    --  The mailman object is used for receiving (POP3)
    --  and sending (SMTP) email.
    DECLARE @mailman int
    EXEC @hr = sp_OACreate 'Chilkat.MailMan2', @mailman OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    --  Any string argument automatically begins the 30-day trial.
    DECLARE @success int

    EXEC sp_OAMethod @mailman, 'UnlockComponent', @success OUT, '30-day trial'
    IF @success <> 1
      BEGIN
        EXEC sp_OAGetProperty @mailman, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        RETURN
      END

    --  Set the POP3 server's hostname
    EXEC sp_OASetProperty @mailman, 'MailHost', 'mail.chilkatsoft.com'

    --  Set the POP3 login/password.
    EXEC sp_OASetProperty @mailman, 'PopUsername', 'myLogin'
    EXEC sp_OASetProperty @mailman, 'PopPassword', 'myPassword'

    DECLARE @bundle int

    --  Copy the all email from the user's POP3 mailbox
    --  into a bundle object.  The email remains on the server.
    EXEC sp_OAMethod @mailman, 'CopyMail', @bundle OUT

    IF @bundle Is NULL 
      BEGIN
        --  The CopyMail failed, examine the LastErrorText
        EXEC sp_OAGetProperty @mailman, 'LastErrorText', @sTmp0 OUT

        PRINT @sTmp0
        RETURN
      END

    EXEC sp_OAGetProperty @bundle, 'MessageCount', @sTmp0 OUT
    IF @sTmp0 > 0
      BEGIN

        EXEC sp_OAGetProperty @bundle, 'MessageCount', @iTmp0 OUT

        PRINT 'Number of messages: ' + @iTmp0
      END
    ELSE
      BEGIN
        --  No messages were received.  If you expected to find messages
        --  you may wish to look at the LastErrorText and the Pop3SessionLog:
        EXEC sp_OAGetProperty @mailman, 'Pop3SessionLog', @sTmp0 OUT

        PRINT @sTmp0
        EXEC sp_OAGetProperty @mailman, 'LastErrorText', @sTmp0 OUT

        PRINT @sTmp0
      END

    EXEC sp_OAMethod @mailman, 'Pop3EndSession', NULL
END
GO

 

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