Question: What is Store and Folder in JavaMail api?Answer: After getting the session you connect to javax.mail.Store class with Authenticator or host, port, user and password information. Store object that implements the specified protocol can be created by by passing the protocol information to the getStore() method of the session object.Store store = session.getStore("pop3"); store.connect(host, username, password); After connecting to store you need to get a folder that holds messages. For POP3, the only folder available is the INBOX but with IMAP, you can have other folders available. For this you can use javax.mail.Folder class. Folder folder = store.getFolder("INBOX"); folder.open(Folder.READ_ONLY); Message message[] = folder.getMessages(); Once you have read messages, you need to close Store and Folder. folder.close(booleanValue); store.close(); |
Is it helpful?
Yes
No
Most helpful rated by users:
- What is JavaMail?
- Explain POP, SMTP and IMAP protocols.
- Discuss about JavaMail.
- Explain the structure of Javamail API
- What are the advantages of JavaMail?