-
1. Re: Willing to pay for answer...
jhudson Sep 7, 2006 3:44 PM (in response to jhudson)Please, can anybody help? I currently am using integrated James but *really* want to switch all the way over to JBoss. But, since it doesn't use the javax.mail.internet.MimeMessage, I'm not sure how to parse the content.
I am willing to pay for the answer... Thanks for your time.
Joe Hudson -
2. Re: Willing to pay for answer...
sappenin Sep 8, 2006 5:09 PM (in response to jhudson)You may want to wait a few days because I think Andy is re-writing some of the code to handle MIME messages.
-
3. Re: Willing to pay for answer...
jhudson Sep 8, 2006 8:23 PM (in response to jhudson)Ok, thank you very much for the reply. I'm sure that will help me. Thank you.
Joe -
4. Re: Willing to pay for answer...
osterday Sep 19, 2006 11:40 AM (in response to jhudson)I'm looking forward to checking out Andy's code as well.
I the mean time, here's what I'm doing - even if it's not pretty, it does work! (I know there are known "problems" with javax.mail, but for the time being we can view messages.)
Sorry, I can't post the complete code for some of the stuff we're doing, but I think this is good enough for a starting point!
You need to get the sender mbean doing something like this:
(There are examples in the JBCS code to see a complete example.)private String chainName = "jboss.mail:type=MailServices,name=MailSender"; sender = (MailSender) JBMailJMXUtil.getMBean(chainName, MailSender.class);
Then you can get the MailboxService from the senderMailboxService mbs = this.sender.getMailboxManager();
I do this in a try/catch - writeMessage is copied from the pop3 code...ByteArrayOutputStream out = new ByteArrayOutputStream(); this.writeMessage(out, message, mbs); ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); String cte = message.getHeader("Content-Transfer-Encoding"); MimeMessage mimeMessage = createMimeMessage(cte, in);
To create a MimeMessage I can use, I do this...
(The content type decoding isn't 100% and I'm not sure why, but works for most things that have content type encoding.)private MimeMessage createMimeMessage(String cte, InputStream in) { Properties props = new Properties(); Session session = Session.getInstance(props); MimeMessage mimeMessage = null; if (cte != null) { cte = cte.trim(); log.debug("Decoding CTE as: " + cte); try { InputStream decodeIs = MimeUtility.decode(in, cte); mimeMessage = new MimeMessage(session, decodeIs); decodeIs.close(); } catch (Exception e) { log.debug("Error creating MIME message. " + e.getMessage()); } } else { try { mimeMessage = new MimeMessage(session, in); } catch (Exception e) { log.debug("Error creating MIME message. " + e.getMessage()); } } return mimeMessage; }
Then you can process the MimeMessage to get the content, attachments, etc.
Hope that helps!