[jboss-user] [Installation, Configuration & Deployment] - Javamail hell with 4.04GA
bezdomny
do-not-reply at jboss.com
Thu Oct 5 10:54:48 EDT 2006
Has anyone gotten javamail to work?? I get ClassNotFoundExceptions when I uses mime/multipart messages and I get SendFailedExceptions "can only send RFC822 compliant messages" when I just use something like the following code:
Session mailSession = null;
try {
Context ctx = new InitialContext();
//Context compEnv = (Context) ctx.lookup("java:comp/env");
//mailSession = (Session)compEnv.lookup("mail/AppMail");
Object objref = ctx.lookup("java:comp/env/mail/AppMail");
mailSession = (Session) PortableRemoteObject.narrow(objref, Session.class);
} catch (NamingException e) {
// TODO Auto-generated catch block
System.out.println(e);
e.printStackTrace();
}
InternetAddress[] address = new InternetAddress[to.length];
for(int i = 0; i < to.length; i++)
{
address = new InternetAddress(to);
}
// Define message
MimeMessage message = new MimeMessage(mailSession);
message.setFrom(new InternetAddress(from));
message.addRecipients(Message.RecipientType.TO,address);
message.setSubject("Hello JavaMail");
message.setText("Welcome to JavaMail");
//I've tried it without this too
message.setHeader("Date",new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z").format(new Date(System.currentTimeMillis())));
// Send message
Transport.send(message);
Someone please enlighten me. I've even tried the new version of javamail with no luck.
B
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3976323#3976323
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3976323
More information about the jboss-user
mailing list