POP3 Object

You can use the POP3 object to establish the connection with the POP3 server and log in mail accounts, learn the number and the size of messages on the server, search for new messages, download message headers and entire messages, and delete messages from the mail account.

Another features of the POP3 object include secure authentication options (OAuth 2.0, APOP, NTLM, GSSAPI/Kerberos and others), Integrated Windows Authentication with no username/password specified, ability to execute user-supplied commands, keep-alive connections support, and more.

Note: By default, the POP3 object neither processes Windows events nor fires its own events. This ensures maximum performance in the server environment such as ASP, but causes the user interface of desktop applications to be not responsive. To enable event handling and firing, you can set EnableEvents property value to True.

Syntax

POP3.property|method

 

Properties
AuthMethod Specifies the authentication method to use when logging in the POP3 mail account.
Busy Indicates whether the POP3 object is in the progress of sending or receiving data.
ClientRequest Returns the last command string sent to the POP3 server.
Connected Indicates whether the POP3 session is active.
EnableEvents Specifies whether the POP3 object will handle and fire events.
EnableLogging Specifies whether the POP3 object must log the POP3 session into a file.
ErrCode Completion status of the last command.
ErrDesc Contains textual error description if the last command has completed with an error.
IsError Indicates whether the last command has completed with errors.
Licensed Indicates whether valid license key has been assigned to the POP3 object.
LicenseKey Sets the license key to be used with the POP3 object.
LogFilePath Sets filename of the POP3 session log file.
MessageCount The total number of messages in the mail account.
Password The password of the user account on the POP3 server.
PortNumber The port number of the POP3 service on the server. Defaults to 110.
ServerName The POP3 server name.
ServerResponse Returns the string that contains the entire last reply from the POP3 server.
Size Returns the size of the specified message in bytes.
SSL Specifies the SSL object to be used to establish secure TLS connection with the POP3 server.
TargetName The SPN of the server (only used with Kerberos authentication).
Timeout The timeout value in seconds.
TotalSize Returns the overall size in bytes of all messages in the mailbox.
UserDomain The name of the user domain on the POP3 server (only used with MS specific authentication types like NTLM).
UserName The name of the user account on the POP3 server.
Methods
Abort Aborts current operation and immediately closes the POP3 session.
ClearLog Clears the POP3 session log file.
Connect Connects to the POP3 server and logs in the user mail account.
DeleteMessage Marks the specified message as "Deleted".
Disconnect Disconnects from the POP3 server.
GetLastReceivedDataChunk Gets the data portion received from the server during last receive-data operation.
GetMessageNumberFromUID Returns the ordinal position of a message given its Unique-ID.
GetMessageUID Returns Unique-ID (UID) value for a message.
Ping Sends NOOP command to the POP3 server.
RetrieveHeaders Downloads all message headers from the mailbox.
RetrieveMessages Downloads all messages from the mailbox.
RetrieveSingleMessage Downloads a message from the mailbox.
RetrieveSingleMessageHeaders Downloads the headers for a message from the mailbox.
Search Returns an array which contains Unique-ID's (UID's) for all messages in the mailbox.
SendCommand Executes user-supplied command on the POP3 server.
Events
OnMessageComplete Fires when the message data just received has been successfully parsed and placed into the Message object.
OnReceiveComplete Fires when the message data has been completely received from the POP3 server.
OnReceiveProgress Fires when new portion of the message data has arrived.
OnReceiveStart Fires when the POP3 object has got ready to retrieve a message from the POP3 server.

 

Remarks

During the development, it's recommended to enable logging the POP3 session into a file by setting EnableLogging and LogFilePath properties. The log file allows you to discover typical problems quickly and easily.

You can find more information on typical problems resolution in Troubleshooting section of the POP3 samples.

 

Example

The following example downloads the headers for all messages in the mailbox, and displays common headers ("From:", "To:", "Subject:", "Date:") to the user. The sample is presented separately in Visual Basic version and ASP version since they differ quite enough.

[Visual Basic]
Dim objPOP3, objMsgs, I

' Create POP3 object
Set objPOP3 = CreateObject("MailBee.POP3")

' Unlock POP3 object
objPOP3.LicenseKey = "put your license key here"

' Set POP3 server name
objPOP3.ServerName = "mail.server.com"

' Set user credentials
objPOP3.UserName = "username"
objPOP3.Password = "password"

' Download the headers for all messages in the mailbox
Set objMsgs = objPOP3.RetrieveHeaders

If objPOP3.IsError Then
  ' Display error information
  MsgBox "Error #" & objPOP3.ErrCode & ", " & objPOP3.ErrDesc
Else
  ' Display the messages info
  For I = 1 To objMsgs.Count
    MsgBox _
      "From: " & objMsgs(I).FromAddr & vbCrLf & _
      "To: " & objMsgs(I).ToAddr & vbCrLf & _
      "Subject: " & objMsgs(I).Subject & vbCrLf & _
      "Date: " & objMsgs(I).Date
  Next
End If

' Close the connection
objPOP3.Disconnect

 

[ASP]
<%
Dim objPOP3, objMsgs, I

' Create POP3 object
Set objPOP3 = Server.CreateObject("MailBee.POP3")

' Unlock POP3 object
objPOP3.LicenseKey = "put your license key here"

' Set POP3 server name
objPOP3.ServerName = "mail.server.com"

' Set user credentials
objPOP3.UserName = "username"
objPOP3.Password = "password"

' Download the headers for all messages in the mailbox
Set objMsgs = objPOP3.RetrieveHeaders

If objPOP3.IsError Then
  ' Display error information
  Response.Write "Error #" & objPOP3.ErrCode & ", " & objPOP3.ErrDesc
Else
  ' Display the messages info.
  ' We use Server.HTMLEncode to convert '<' and '>'
  ' characters which can disturb the output if they
  ' are contained in the message headers.
  For I = 1 To objMsgs.Count
    Response.Write _
      "From: " & Server.HTMLEncode(objMsgs(I).FromAddr) & "<br>" & _
      "To: " & Server.HTMLEncode(objMsgs(I).ToAddr) & "<br>" & _
      "Subject: " & Server.HTMLEncode(objMsgs(I).Subject) & "<br>" & _
      "Date: " & objMsgs(I).Date & vbCrLf & "<hr>"
  Next
End If

' Close the connection
objPOP3.Disconnect
%>

 

See Also

Message Object

 


Send feedback to AfterLogic
Copyright © 2002-2022, AfterLogic Corporation. All rights reserved.