Part I Development Tasks and Tools
1. Setting Up a Development Environment
Part II Developing Applications and Application Components
6. Using the Java Persistence API
7. Developing Web Applications
8. Using Enterprise JavaBeans Technology
9. Using Container-Managed Persistence
12. Developing Lifecycle Listeners
13. Developing OSGi-enabled Java EE Applications
Part III Using Services and APIs
14. Using the JDBC API for Database Access
15. Using the Transaction Service
16. Using the Java Naming and Directory Interface
17. Using the Java Message Service
Sending and Reading Messages Using JavaMail
To Send a Message Using JavaMail
To Read a Message Using JavaMail
The JavaMail API defines classes such as Message, Store, and Transport. The API can be extended and can be subclassed to provide new protocols and to add functionality when necessary. In addition, the API provides concrete subclasses of the abstract classes. These subclasses, including MimeMessage and MimeBodyPart, implement widely used Internet mail protocols and conform to the RFC822 and RFC2045 specifications. The JavaMail API includes support for the IMAP4, POP3, and SMTP protocols.
The JavaMail architectural components are as follows:
The abstract layer declares classes, interfaces, and abstract methods intended to support mail handling functions that all mail systems support.
The internet implementation layer implements part of the abstract layer using the RFC822 and MIME internet standards.
JavaMail uses the JavaBeans Activation Framework (JAF) to encapsulate message data and to handle commands intended to interact with that data.
For more information, see Chapter 16, Administering the JavaMail Service, in Oracle GlassFish Server 3.1 Administration Guide and the JavaMail specification at http://www.oracle.com/technetwork/java/javamail/index.html. A useful JavaMail tutorial is located at http://java.sun.com/developer/onlineTraining/JavaMail/.