Sample code for 30+ languages & platforms
Classic ASP

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 Classic ASP Downloads

Classic ASP
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 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.

set mailman = Server.CreateObject("Chilkat.MailMan")

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

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

success = mailman.Pop3BeginSession()
If (success = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( mailman.LastErrorText) & "</pre>"
    Response.End
End If

'  Perform one or more mailbox operations within this single session.
Response.Write "<pre>" & Server.HTMLEncode( "Mailbox count: " & mailman.GetMailboxCount()) & "</pre>"

'  End the session when finished.
success = mailman.Pop3EndSession()
If (success = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( mailman.LastErrorText) & "</pre>"
    Response.End
End If

Response.Write "<pre>" & Server.HTMLEncode( "POP3 session completed.") & "</pre>"

%>
</body>
</html>