Sample code for 30+ languages & platforms
Xbase++

Send a Raw IMAP Command

See more IMAP Examples

Demonstrates the Chilkat Imap.SendRawCommand method, which sends raw IMAP command text and returns the raw server response. Pass the command itself (such as NOOP) without an IMAP tag — Chilkat adds the tag automatically. This example sends a raw NOOP.

Background: Every IMAP command a client sends is prefixed with a short unique tag (like a001) so the client can match the tagged completion response to the command it issued. SendRawCommand handles that tagging for you and returns the server's reply verbatim — an escape hatch for issuing a command Chilkat doesn't wrap directly, or a server-specific extension, without leaving the established authenticated session.

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oImap
LOCAL cResponse

nSuccess := 0

//  Demonstrates the Imap.SendRawCommand method, which sends raw IMAP command text and returns
//  the raw server response.  Pass the command itself (such as NOOP) without an IMAP tag --
//  Chilkat adds the tag automatically.

oImap := CreateObject("Chilkat.Imap")

oImap:Ssl := 1
oImap:Port := 993

nSuccess := oImap:Connect("imap.example.com")
IF (nSuccess == 0)
    ? oImap:LastErrorText
    oImap:destroy()
    RETURN
ENDIF

nSuccess := oImap:Login("user@example.com", "myPassword")
IF (nSuccess == 0)
    ? oImap:LastErrorText
    oImap:destroy()
    RETURN
ENDIF

//  Send a raw IMAP command and read the raw response.
cResponse := oImap:SendRawCommand("NOOP")
IF (oImap:LastMethodSuccess == 0)
    ? oImap:LastErrorText
    oImap:destroy()
    RETURN
ENDIF

? cResponse

nSuccess := oImap:Disconnect()
IF (nSuccess == 0)
    ? oImap:LastErrorText
    oImap:destroy()
    RETURN
ENDIF

oImap:destroy()