camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Raul Kripalani <r...@evosent.com>
Subject Re: Mail attachements
Date Thu, 20 Dec 2012 18:58:18 GMT
Try explicitly setting the Charset in the Exchange.CHARSET_NAME [1]
exchange property, for example:

<setProperty
propertyName="CamelCharsetName"><constant>UTF-8</constant></setProperty>

[1]
http://camel.apache.org/maven/current/camel-core/apidocs/constant-values.html#org.apache.camel.Exchange.CHARSET_NAME

Regards,

*Raúl Kripalani*
Apache Camel Committer
Enterprise Architect, Program Manager, Open Source Integration specialist
http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
http://blog.raulkr.net | twitter: @raulvk <http://twitter.com/raulvk>

On Thu, Dec 20, 2012 at 4:35 PM, developpef <src182@orange.fr> wrote:

> Hello everyone,
>
> I am facing the following issue when trying to send an email with
> attachments :
>
> My route is :
>
> from("direct:mail")
>                 .setHeader("To", constant(mailTo))
>             .setHeader("From", constant(mailFrom))
>             .setHeader("Subject", constant(mailSubject))
>             .beanRef(MAIL_ATTACHER, "attachLog")
>             .transform(constant(mailBody))
>
> .to("smtp://${mailUser}@
> ${mailServer}:${mailPort}?password=${mailPassword}");
>
> And my bean "MAIL_ATTACHER" :
>
> public class MailAttacher {
>
>     private LogFileResolver logResolver;
>
>     public void attachLog(Exchange exc) {
>         File logToAttach = logResolver.getCurrentLogFile();
>         exc.getIn().addAttachment(logToAttach.getName(),
>                 new DataHandler(new FileDataSource(logToAttach)));
>     }
>
> }
>
> So I expected my mail to be sent, but here is the stacktrace raised :
>
> java.lang.NullPointerException
>         at
> javax.mail.internet.MimeUtility.getEncoding(MimeUtility.java:226)
>         at
> javax.mail.internet.MimeUtility.getEncoding(MimeUtility.java:299)
>         at
> javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1375)
>         at
> javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1021)
>         at
> javax.mail.internet.MimeMultipart.updateHeaders(MimeMultipart.java:419)
>         at
> javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1354)
>         at
> javax.mail.internet.MimeMessage.updateHeaders(MimeMessage.java:2107)
>         at
> javax.mail.internet.MimeMessage.saveChanges(MimeMessage.java:2075)
>         at
>
> org.apache.camel.component.mail.DefaultJavaMailSender.send(DefaultJavaMailSender.java:118)
>         at
> org.apache.camel.component.mail.MailProducer.process(MailProducer.java:49)
>         at
>
> org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
>         at
>
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>
> And when I tried to set the property "defaultEncoding=UTF-8" I had an error
> saying that the property is not allowed on the endpoint (camel v2.10.2)
>
> The mail is correctly sent without attachments...
>
> Does anyone have an idea about how to resolve this?
>
> Thanks a lot!
>
>
>
> -----
> http://developpef.blogspot.com
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Mail-attachements-tp5724461.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message