Show TOC

Procedure documentationReceiving E-Mail Messages Locate this document in the navigation structure

Procedure

1. Obtain the POP3 Protocol Implementation

The javax.mail.Store object is used for receiving e-mail messages. It is an abstract class that represents the POP3 protocol implementation.

You obtain a Store object by calling the getStore("pop3") method of the session object.

2. Specify the POP3 Server

There are two ways to specify the connection settings for the POP3 server:

  • Using the respective service property

    This method specifies globally a POP3 server to be used for all receiving operations in applications. You need to edit the value of the Pop3 property of the JavaMail Client Service. It represents the host address or name of the POP3 server.

    You can set the value of this property using the NetWeaver Administrator.

    More information: Java System Properties.

  • Using the connect method of the Store object

    The connect method has variants that allow you to specify the server host, port and user account, if necessary.

If you do not specify the port for connection, the default POP3 port (110) is used.

3. Receive the Messages

You can receive e-mail messages by their folder. Use the getFolder method or the other respective methods of the Store object to retrieve particular folder or folders as javax.mail.Folder objects. Then call the getMessages() or another respective method of the Folder object to retrieve the messages you need.

Example

The following example illustrates getting a Store object and retrieving all messages available in the INBOX folder.

Syntax Syntax

  1.     Store store = ses.getStore("pop3");
        store.connect(host, user, pass);
        Folder folder = store.getFolder("INBOX");
        Message[] messages = folder.getMessages();
    
End of the code.