Claus, I'm not a contributor on the Camel project, but here's what I would advocate trying in MailBinding.java, expanding the meaning of "ignoreUnsupportedCharset" a bit:
public Object extractBodyFromMail(Exchange exchange, Message message) { return extractBodyFromMail(exchange, message, false); } private Object extractBodyFromMail(Exchange exchange, Message message, boolean isSecondAttempt) { try { return message.getContent(); } catch (Exception e) { if (!isSecondAttempt && (e instanceof java.io.UnsupportedEncodingException || (e.getCause() != null && e.getCause() instanceof java.io.UnsupportedEncodingException)) && configuration.isIgnoreUnsupportedCharset()) { // The charset is unsupported, but we've been configured to // ingore that condition. Let's at least attempt to rewrite // the Content-Type header and omit the unsupported charset. // This may wreak havoc down the line, but it's better than // Camel just bailing on this exchange, and ending up retrying // this same message over and over, and failing every time... String contentType = message.getContentType(); if (contentType != null) { // Wipe out the charset=... from the Content-Type header contentType = contentType.replaceAll("\\s*charset=[^;\\s]+", ""); part.setHeader("Content-Type", contentType); // Try again...pass isSecondAttempt=true this time return extractBodyFromMail(exchange, message, true); } } else { throw new RuntimeCamelException("Failed to extract body due to: " + e.getMessage() + ". Exchange: " + exchange + ". Message: " + message, e); } } } What do you think? Claus Ibsen-2 wrote: > > On Wed, Nov 4, 2009 at 7:24 PM, dcheckoway <dchecko...@gmail.com> wrote: >> >> Is there any way to "intercept" the raw mail message content before it >> gets >> passed to the java mail API? I would be happy to manually munge the >> Content-Type header if I detect one of the known-to-be-funky charsets in >> there. >> > > You can use a custom MailBinding class, e.g. extending the on in > camel-maill. > -- View this message in context: http://old.nabble.com/Camel-Mail-issue-with-unsupported-charset-tp24755585p26206832.html Sent from the Camel - Users mailing list archive at Nabble.com.