The built-in functions in the POP3Session class provide the ability to connect to a POP3 server with a variety of methods and retrieve email and send POP3 commands.

The POP3Session class offers the following functionality:

  • New() Creates a new POP3 session object.
  • SetTimeout() and GetTimeout() to get or set the POP3 command timeout value.
  • ServerHasUIDs() to detect if a server supports UIDs.
  • InitContext() to initialize an SSL context for secure connections.
  • SecureLogin() and Login() to login to the POP3 server.
  • Close() to close a POP3 connection.
  • ListMessages(), MessageCount(), RetrieveMessage(), RetrieveHeader(), DeleteMessage(), ListMessage(), GetUID() for message management on the POP3 server.
  • GetLastError() to return a string for the last error that occured.

  • Class Methods Index

     o POP3Session New ( String host, Integer port )
    Returns a new POP3Session instance, or undefined if an error occured.

    Function Constants Index

    POP3Session New() port parameters

     o POP3_PORT
    The standard POP3 port, 110
     o SECURE_POP3_PORT
    The standard Secure POP3 port, 995

    ListMessages() Constants

     o LIST_BY_IDS
    List messages by IDs
     o LIST_BY_UIDS
    List messages by UIDs

    Instance Methods Index

     o Integer Close( )
    Close a connection to an POP3 server.
     o Integer DeleteMessage( Dynamic messageIndex )
    deletes a message from the POP3 server.
     o String GetLastError()
    Retrieve the a string for the last error code.
     o Integer GetTimeout( )
    Returns the POP3 timeout in milliseconds.
     o String GetUID( Integer messageIndex )
    retrieves a UID for a message on the POP3 server.
     o Integer InitContext ( SSLOptions options )
    Used to initialize a security context for SecureLogin().
     o Integer ListMessage( Dynamic messageIndex )
    retrieves the size of a message from the POP3 server.
     o List ListMessages( Integer listType )
    retrieves a list of messages from the POP3 server.
     o Integer Login( String username, String password )
    Initiate a connection to an POP3 server.
     o Integer MessageCount( )
    returns the number of messages for the logged in account.
     o List RetrieveHeader( Dynamic messageIndex )
    retrieves a message header from the POP3 server.
     o MailMessage RetrieveMessage( Dynamic messageIndex )
    retrieves a message from the POP3 server.
     o Integer SecureLogin ( String username, String password )
    Initiate a secure connection to an POP3 server.
     o Integer SendCommand( String command, String arguments )
    Sends raw POP3 commands.
     o Boolean ServerHasUIDs ()
    Returns true if the server supports UIDL command, false otherwise.
     o Integer SetTimeout( Integer timeout )
    Set POP3 timeout in milliseconds.

    Class Methods

     o New
     POP3Session New( String host,
     		 [Integer port] )
            
    

    Returns a new POP3Session object

    Parameters:
    host  -  IP address or domain name of POP3 host.
    port  -  POP3 connection port, optional and defaults to 110
    Returns:
    A new POP3Session object or undefined if there was an error constructing the object.

    Instance Methods

     o Close
     Integer Close()
    

    No parameters. Closes the session.

    Parameters:
    None
    Returns:
    Returns 0 for success and -1 if an error occurred.
     o DeleteMessage
     Integer DeleteMessage(
     		 Dynamic messageIndex )
    

    The messageIndex parameter can be either an Integer ID or a String UID. Marks the specified message for deletion on the server.

    Parameters:
    messageIndex  -  either an Integer ID or a String UID of the message to retrieve
    Returns:
    Returns 0 if successful, -1 if any errors occurred.
     o GetLastError
     String GetLastError( )
    

    No parameters. Returns an error string for the last error that occured.

    Parameters:
    None.
    Returns:
    Returns an error string for the last error that occured.
     o GetTimeout
     Integer GetTimeout()
    

    Gets the timeout value for POP3 commands. The timeout is in milliseconds.

    Parameters:
    None
    Returns:
    Returns the timeout in milliseconds, -1 if an error occured.
     o GetUID
     String GetUID(
     		 Integer messageIndex )
    

    Returns the UID for the given message. If no message exists, returns and empty string.

    Parameters:
    messageIndex  -  ID of the message to retrieve
    Returns:
    Returns the UID for the given message. If no message exists, returns and empty string.
     o InitContext
     Integer InitContext(
                 	 SSLOptions options )
    

    Sets the SSL options for a secure connection. You must call this before attempting to do a SecureLogin() call.

    Parameters:
    options  -  an instance of SSLOptions.
    Returns:
    Returns 0 for success and -1 if an error occurred.
     o ListMessage
     Integer ListMessage(
     		 Dynamic messageIndex )
    

    The messageIndex parameter can be either an Integer ID or a String UID. Returns the size of the message specified by mesgIndex or -1 if any errors occurred.

    Parameters:
    messageIndex  -  either an Integer ID or a String UID of the message to retrieve
    Returns:
    Returns the size of the message specified by mesgIndex or -1 if any errors occurred.
     o ListMessages
     List ListMessages(
                  [Integer listType] )
    

    If listType is not specified or LIST_BY_IDS, then it returns a List of the message ids and sizes, one after the other. Ie, 1,234,2,3435,3,5430. If listType is LIST_BY_UIDS, then it returns a List of the message ids and their UID strings, one after the other, ie, 1,34DF32EAC3,2,64EA32EDC3,3,354456CAE3.

    Parameters:
    listType  -  type of list to return, either LIST_BY_IDS, or LIST_BY_UIDS.
    Returns:
    Returns a list of ids.
     o Login
     Boolean Login(
                  String username,
                  String password )
    

    The client will check server capabilities and authenticate using CRAM-MD5 if available automatically, otherwise, it will login with CLEAR.

    Parameters:
    username  -  username used to login to POP3 server.
    password  -  password used to login to POP3 server.
    Returns:
    Returns TRUE for success and FALSE if an error occurred.
     o MessageCount
     Integer MessageCount()
    

    No parameters. Returns the number of messages for the logged in user on the POP3 server.

    Parameters:
    None.
    Returns:
    Returns the number of messages for the logged in user on the POP3 server.
     o RetrieveHeader
     List RetrieveHeader(
     		 Dynamic messageIndex )
    

    The messageIndex parameter can be either an Integer ID or a String UID. Returns a List composed of the key/value string pairs found in the header of the given message. The return value will be Undefined if no message exists at that index. Ie, key1, value1, key2, value2, etc.

    Parameters:
    messageIndex  -  either an Integer ID or a String UID of the message to retrieve
    Returns:
    Returns a List for the given mesgIndex. The return value will be Undefined if no message exists at that index.
     o RetrieveMessage
     MailMessage RetrieveMessage(
     		 Dynamic messageIndex )
    

    The messageIndex parameter can be either an Integer ID or a String UID. Returns a MailMessage class for the given messageIndex. The return value will be Undefined if no message exists at that index.

    Parameters:
    messageIndex  -  either an Integer ID or a String UID of the message to retrieve
    Returns:
    Returns a MailMessage class for the given mesgIndex. The return value will be Undefined if no message exists at that index.
     o SecureLogin
     Integer SecureLogin(
                  String username,
                  String password )
    

    Does an SSL secure login. You must have called InitContext() before this.

    Parameters:
    username  -  user login on POP3 server
    password  -  user password for POP3 server
    Returns:
    Returns 0 for success and -1 if an error occurred.
     o SendCommand
     Integer SendCommand(
                  String command,
                  [String arguments] )
    

    Use this to send other raw POP3 commands. The arguments param is optional.

    Parameters:
    command  -  command to send
    arguments  -  command arguments to send
    Returns:
    Returns 0 for success and -1 if an error occurred.
     o ServerHasUIDs
     Boolean ServerHasUIDs()
    

    Returns TRUE if the server supports UIDL command, FALSE otherwise

    Parameters:
    None
    Returns:
    TRUE if the server supports UIDL command, FALSE otherwise.
     o SetTimeout
     Integer SetTimeout(
                  Integer timeout )
    

    Sets the timeout value for POP3 commands. The timeout is in milliseconds.

    Parameters:
    timeout  -  timeout in milliseconds.
    Returns:
    Returns 0 for success and -1 if an error occurred.