A program can conduct a JNDI lookup of a JavaMail resource. Deployment descriptors of the application determine the lookup name that you specify.
The following example shows a lookup of a JavaMail resource:
// Get the initial context as shown above ... Session session = (Session) initialContext.lookup("java:comp/env/mail/MailSession");