PureBasic
PureBasic
Explicitly Begin a POP3 Session
See more POP3 Examples
Demonstrates the Chilkat MailMan.Pop3BeginSession method, which explicitly begins a POP3 session by connecting to the POP3 server and authenticating using the current POP3 property settings. Calling it is optional. This example begins a session, performs a mailbox operation, and ends the session.
Background:
Pop3BeginSession combines connecting and authenticating into one call. Chilkat does this automatically when a mailbox operation needs it, so the value of calling it explicitly is control: you open one session, perform several operations against it, and close it with Pop3EndSession — avoiding repeated connect/authenticate round trips and keeping deletion marks within a single, well-defined session.Chilkat PureBasic Downloads
IncludeFile "CkMailMan.pb"
Procedure ChilkatExample()
success.i = 0
; Demonstrates the MailMan.Pop3BeginSession method, which explicitly begins a POP3 session
; by connecting to the POP3 server and authenticating using the current POP3 property
; settings.
mailman.i = CkMailMan::ckCreate()
If mailman.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
; Configure the POP3 server connection.
CkMailMan::setCkMailHost(mailman, "pop.example.com")
CkMailMan::setCkMailPort(mailman, 995)
CkMailMan::setCkPopSsl(mailman, 1)
CkMailMan::setCkPopUsername(mailman, "user@example.com")
CkMailMan::setCkPopPassword(mailman, "myPassword")
; Explicitly begin the POP3 session (connect + authenticate).
success = CkMailMan::ckPop3BeginSession(mailman)
If success = 0
Debug CkMailMan::ckLastErrorText(mailman)
CkMailMan::ckDispose(mailman)
ProcedureReturn
EndIf
; Perform one or more mailbox operations within this single session.
Debug "Mailbox count: " + Str(CkMailMan::ckGetMailboxCount(mailman))
; End the session when finished.
success = CkMailMan::ckPop3EndSession(mailman)
If success = 0
Debug CkMailMan::ckLastErrorText(mailman)
CkMailMan::ckDispose(mailman)
ProcedureReturn
EndIf
Debug "POP3 session completed."
CkMailMan::ckDispose(mailman)
ProcedureReturn
EndProcedure