PowerBuilder
PowerBuilder
Test for an IMAP Server Capability
See more IMAP Examples
Demonstrates the Chilkat Imap.HasCapability method, which tests whether a named capability appears in a raw capability response. The second argument is typically the string returned by the Capability method. This example checks whether the server supports the IDLE extension.
Background: Rather than scanning the raw
CAPABILITY text yourself, HasCapability parses it for a specific token. This is the right guard before using any optional feature — for example, only entering an IDLE wait loop, or using the MOVE command, when the server actually advertises it. Fetch the capability string once and test it as many times as needed.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Imap
string ls_Capabilities
integer li_HasIdle
li_Success = 0
// Demonstrates the Imap.HasCapability method, which tests whether a named capability appears
// in a raw capability response. The 2nd argument is typically the string returned by the
// Capability method.
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
// Get the raw capability response.
ls_Capabilities = loo_Imap.Capability()
if loo_Imap.LastMethodSuccess = 0 then
Write-Debug loo_Imap.LastErrorText
destroy loo_Imap
return
end if
// Test whether the server supports the IDLE extension.
li_HasIdle = loo_Imap.HasCapability("IDLE",ls_Capabilities)
if li_HasIdle = 1 then
Write-Debug "The server supports IDLE."
else
Write-Debug "The server does not support IDLE."
end if
li_Success = loo_Imap.Disconnect()
if li_Success = 0 then
Write-Debug loo_Imap.LastErrorText
destroy loo_Imap
return
end if
destroy loo_Imap