DataFlex
DataFlex
Send a Raw IMAP Command (Binary)
See more IMAP Examples
Demonstrates the Chilkat Imap.RawCommandBd method, which sends raw IMAP command bytes and receives the raw response bytes. The first argument is a BinData holding the command — without an IMAP tag or trailing CRLF, which Chilkat supplies — and the second is a BinData that receives the response.
Background: This is an escape hatch for rare server extensions the API does not otherwise expose. It is intended for commands with a single-line response that do not change
Imap object state such as the selected mailbox or message count. For everyday operations, use the dedicated methods, which parse responses and maintain object state for you.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoImap
Variant vBdCmd
Handle hoBdCmd
Variant vBdResp
Handle hoBdResp
String sRespStr
String sTemp1
Move False To iSuccess
// Demonstrates the Imap.RawCommandBd method, which sends raw IMAP command bytes and receives
// the raw response bytes. The 1st argument is a BinData containing the command (without a tag
// or trailing CRLF -- Chilkat supplies both), and the 2nd is a BinData that receives the
// response.
Get Create (RefClass(cComChilkatImap)) To hoImap
If (Not(IsComObjectCreated(hoImap))) Begin
Send CreateComObject of hoImap
End
Set ComSsl Of hoImap To True
Set ComPort Of hoImap To 993
Get ComConnect Of hoImap "imap.example.com" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoImap To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComLogin Of hoImap "user@example.com" "myPassword" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoImap To sTemp1
Showln sTemp1
Procedure_Return
End
// Build the raw command. Do not include an IMAP tag or a trailing CRLF.
Get Create (RefClass(cComChilkatBinData)) To hoBdCmd
If (Not(IsComObjectCreated(hoBdCmd))) Begin
Send CreateComObject of hoBdCmd
End
Get ComAppendString Of hoBdCmd "CAPABILITY" "utf-8" To iSuccess
Get Create (RefClass(cComChilkatBinData)) To hoBdResp
If (Not(IsComObjectCreated(hoBdResp))) Begin
Send CreateComObject of hoBdResp
End
Get pvComObject of hoBdCmd to vBdCmd
Get pvComObject of hoBdResp to vBdResp
Get ComRawCommandBd Of hoImap vBdCmd vBdResp To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoImap To sTemp1
Showln sTemp1
Procedure_Return
End
// Interpret the response bytes as a UTF-8 string.
Get ComGetString Of hoBdResp "utf-8" To sRespStr
Showln sRespStr
Get ComDisconnect Of hoImap To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoImap To sTemp1
Showln sTemp1
Procedure_Return
End
End_Procedure