Sample code for 30+ languages & platforms
Visual FoxPro

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 Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loMailman

lnSuccess = 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.

loMailman = CreateObject('Chilkat.MailMan')

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

*  Explicitly begin the POP3 session (connect + authenticate).

lnSuccess = loMailman.Pop3BeginSession()
IF (lnSuccess = 0) THEN
    ? loMailman.LastErrorText
    RELEASE loMailman
    CANCEL
ENDIF

*  Perform one or more mailbox operations within this single session.
? "Mailbox count: " + STR(loMailman.GetMailboxCount())

*  End the session when finished.
lnSuccess = loMailman.Pop3EndSession()
IF (lnSuccess = 0) THEN
    ? loMailman.LastErrorText
    RELEASE loMailman
    CANCEL
ENDIF

? "POP3 session completed."

RELEASE loMailman