Sample code for 30+ languages & platforms
PowerBuilder

Send a Raw POP3 Command

See more POP3 Examples

Demonstrates the Chilkat MailMan.Pop3SendRawCommand method, which sends a raw command to the POP3 server and returns the server's response. The second argument specifies the charset to use if the command contains non-US-ASCII characters. This example sends the POP3 STAT command within an open session.

Background: POP3 is a simple line-based text protocol — the client sends short commands like STAT, LIST, UIDL, or RETR and the server replies with +OK or -ERR. This method is an escape hatch for issuing a command Chilkat doesn't wrap directly, or a server-specific extension. Note that the session must already be open, since a raw command assumes an authenticated connection.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Mailman
string ls_Response

li_Success = 0

//  Demonstrates the MailMan.Pop3SendRawCommand method, which sends a raw command to the POP3
//  server and returns the server's response.  The second argument is the charset used if the
//  command contains non-US-ASCII characters.

loo_Mailman = create oleobject
li_rc = loo_Mailman.ConnectToNewObject("Chilkat.MailMan")
if li_rc < 0 then
    destroy loo_Mailman
    MessageBox("Error","Connecting to COM object failed")
    return
end if

//  Configure the POP3 server connection.
loo_Mailman.MailHost = "pop.example.com"
loo_Mailman.MailPort = 995
loo_Mailman.PopSsl = 1
loo_Mailman.PopUsername = "user@example.com"
loo_Mailman.PopPassword = "myPassword"

li_Success = loo_Mailman.Pop3BeginSession()
if li_Success = 0 then
    Write-Debug loo_Mailman.LastErrorText
    destroy loo_Mailman
    return
end if

//  Send the raw POP3 STAT command, which returns the message count and maildrop size.
ls_Response = loo_Mailman.Pop3SendRawCommand("STAT","us-ascii")
if loo_Mailman.LastMethodSuccess = 0 then
    Write-Debug loo_Mailman.LastErrorText
    destroy loo_Mailman
    return
end if

Write-Debug "STAT response: " + ls_Response

li_Success = loo_Mailman.Pop3EndSession()
if li_Success = 0 then
    Write-Debug loo_Mailman.LastErrorText
    destroy loo_Mailman
    return
end if



destroy loo_Mailman