How do you use the JNDI ENC to access JavaMail?

Steven Lau

First of all, you have to create a javax.mail.Session like you would in accessing other resources such as JDBC connections:

InitialContext ctx = new InitialContext();
Session session = 
  (Session) ctx.lookup("java:comp/env/TheMailSession");
After that, everything else is the same:

Message msg = new MimeMessage(session);
Depending on the application server you're using, you'll have different ways in setting up the ENC.
0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact