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
|
Send IMAP Raw Command and Receive ResponseDemonstrates how to send an arbitrary (raw) command to an IMAP server and receive the response. This example will set the "Seen" flag for an email with a pre-known UID. Note: Normally, you would call the SetFlag method to set a flag. This example only serves to show how SendRawCommand is used.
CREATE PROCEDURE ChilkatSample AS BEGIN DECLARE @hr int DECLARE @sTmp0 nvarchar(4000) DECLARE @imap int EXEC @hr = sp_OACreate 'Chilkat.Imap', @imap OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END DECLARE @success int -- Anything unlocks the component and begins a fully-functional 30-day trial. EXEC sp_OAMethod @imap, 'UnlockComponent', @success OUT, 'Anything for 30-day trial' IF @success <> 1 BEGIN EXEC sp_OAGetProperty @imap, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 RETURN END EXEC sp_OASetProperty @imap, 'KeepSessionLog', 1 -- Connect to an IMAP server. EXEC sp_OAMethod @imap, 'Connect', @success OUT, 'mail.chilkatsoft.com' IF @success <> 1 BEGIN EXEC sp_OAGetProperty @imap, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 RETURN END -- Login EXEC sp_OAMethod @imap, 'Login', @success OUT, '***', '***' IF @success <> 1 BEGIN EXEC sp_OAGetProperty @imap, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 RETURN END -- Select an IMAP mailbox EXEC sp_OAMethod @imap, 'SelectMailbox', @success OUT, 'Inbox' IF @success <> 1 BEGIN EXEC sp_OAGetProperty @imap, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 RETURN END -- Assume we know that the UID for the email in question is 2: DECLARE @response nvarchar(4000) EXEC sp_OAMethod @imap, 'SendRawCommand', @response OUT, 'UID STORE 2 +FLAGS.SILENT (\Seen)' PRINT @response -- Disconnect from the IMAP server. EXEC sp_OAMethod @imap, 'Disconnect', NULL EXEC sp_OAGetProperty @imap, 'SessionLog', @sTmp0 OUT PRINT @sTmp0 END GO |
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.