PowerBuilder
PowerBuilder
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 PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Imap
oleobject loo_BdCmd
oleobject loo_BdResp
string ls_RespStr
li_Success = 0
// 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.
loo_Imap = create oleobject
li_rc = loo_Imap.ConnectToNewObject("Chilkat.Imap")
if li_rc < 0 then
destroy loo_Imap
MessageBox("Error","Connecting to COM object failed")
return
end if
loo_Imap.Ssl = 1
loo_Imap.Port = 993
li_Success = loo_Imap.Connect("imap.example.com")
if li_Success = 0 then
Write-Debug loo_Imap.LastErrorText
destroy loo_Imap
return
end if
li_Success = loo_Imap.Login("user@example.com","myPassword")
if li_Success = 0 then
Write-Debug loo_Imap.LastErrorText
destroy loo_Imap
return
end if
// Build the raw command. Do not include an IMAP tag or a trailing CRLF.
loo_BdCmd = create oleobject
li_rc = loo_BdCmd.ConnectToNewObject("Chilkat.BinData")
loo_BdCmd.AppendString("CAPABILITY","utf-8")
loo_BdResp = create oleobject
li_rc = loo_BdResp.ConnectToNewObject("Chilkat.BinData")
li_Success = loo_Imap.RawCommandBd(loo_BdCmd,loo_BdResp)
if li_Success = 0 then
Write-Debug loo_Imap.LastErrorText
destroy loo_Imap
destroy loo_BdCmd
destroy loo_BdResp
return
end if
// Interpret the response bytes as a UTF-8 string.
ls_RespStr = loo_BdResp.GetString("utf-8")
Write-Debug ls_RespStr
li_Success = loo_Imap.Disconnect()
if li_Success = 0 then
Write-Debug loo_Imap.LastErrorText
destroy loo_Imap
destroy loo_BdCmd
destroy loo_BdResp
return
end if
destroy loo_Imap
destroy loo_BdCmd
destroy loo_BdResp