You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Mattias Severson <ma...@gmail.com> on 2010/06/23 08:16:59 UTC

Email character encoding?

Hi,

I am having trouble sending ISO-8859-1 characters, e.g. åäö, in emails. I
have tried to set the defaultEncoding option of the 
http://camel.apache.org/mail.html Camel Mail  component to ISO-8859-1, but
that did not solve the problem. 

The sender is implemented as

producerTemplate.sendBodyAndHeaders(emailRecipientUri, emailBody,
camelEmailHeaders);

and I am using Camel 2.3.0


Any ideas?

/Mattias




-- 
View this message in context: http://camel.465427.n5.nabble.com/Email-character-encoding-tp510814p510814.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Email character encoding?

Posted by Willem Jiang <wi...@gmail.com>.
Mattias Severson wrote:
> I am indeed using Mac OS X for development, i.e. that is where Camel is used.
> However, the smtp server is running on a Linux machine. 
> 
> I updated the header to 
> headers.put(Exchange.CONTENT_TYPE, "text/plain; charset=ISO-8859-1");,
> updated to Camel 2.4.SNAPSHOT and I can confirm that your patch solves my
> problem on the previously specified email clients (Gmail, Thunderbird and
> Apple Mail). Well done!
> 
> When I try to apply the same solution using Camel 2.3.0, it works in most
> cases, except for the email subject in Gmail and the email subject in email
> list in Thunderbird.
> 
> Thank you very much for your support and your rapid response.

You need apply the patch of CAMEL-2857[1] into Camel 2.3.0 yourself to 
resolve the subject issue.

[1]https://issues.apache.org/activemq/browse/CAMEL-2857

Willem
----------------------------------
Apache Camel, Apache CXF committer
Open SOA http://www.fusesource.com
Blog http://willemjiang.blogspot.com
Tiwtter http://twitter.com/willemjiang

Re: Email character encoding?

Posted by Mattias Severson <ma...@gmail.com>.
I am indeed using Mac OS X for development, i.e. that is where Camel is used.
However, the smtp server is running on a Linux machine. 

I updated the header to 
headers.put(Exchange.CONTENT_TYPE, "text/plain; charset=ISO-8859-1");,
updated to Camel 2.4.SNAPSHOT and I can confirm that your patch solves my
problem on the previously specified email clients (Gmail, Thunderbird and
Apple Mail). Well done!

When I try to apply the same solution using Camel 2.3.0, it works in most
cases, except for the email subject in Gmail and the email subject in email
list in Thunderbird.

Thank you very much for your support and your rapid response.
-- 
View this message in context: http://camel.465427.n5.nabble.com/Email-character-encoding-tp510814p511664.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Email character encoding?

Posted by Willem Jiang <wi...@gmail.com>.
Hi Mattias,

You can specify the charset of Mail message by setting this header.

headers.put(Exchange.CONTENT_TYPE, "text/plain; charset=ISO-8859-1");

I just did some test with latest camel trunk code with this change[1], 
now Gmail is happy with the camel-mail message subject and body.

[1]https://issues.apache.org/activemq/browse/CAMEL-2870


Willem
----------------------------------
Apache Camel, Apache CXF committer
Open SOA http://www.fusesource.com
Blog http://willemjiang.blogspot.com
Tiwtter http://twitter.com/willemjiang


Mattias Severson wrote:
> I created a new route which I added to my camel context:
> from("direct:send").setProperty(Exchange.CHARSET_NAME, new
> ConstantExpression("ISO-8859-1")).to("smtp://myserver");
> 
> And then I updated the producer template:
> producerTemplate.sendBodyAndHeaders("direct:send", body, camelEmailHeader);
> 
> The actual recipient address is specified in the camelEmailHeader.get("to")
> 
> The mail I send has the subject "Subject åäö ÅÄÖ" and the body "Body åäö
> ÅÄÖ"
> 
> There are still some problems, depending on which email client I use. 
> 
> Gmail: 
> The subject is displayed as "Subject: едц ЕДЦ"
> The body is displayed correctly
> 
> Thunderbird: 
> In the email list, the subject is displayed as "Subject: ??? ???"
> In the email itself, the subject displayed correctly
> The body is displayed as "Body åäö ÅÄÖ"
> 
> Apple mail:
> Both the subject and the body are displayed correctly
> 


Re: Email character encoding?

Posted by Willem Jiang <wi...@gmail.com>.
Did you sent the mail from a Mac OSX ?

Willem

Mattias Severson wrote:
> I created a new route which I added to my camel context:
> from("direct:send").setProperty(Exchange.CHARSET_NAME, new
> ConstantExpression("ISO-8859-1")).to("smtp://myserver");
> 
> And then I updated the producer template:
> producerTemplate.sendBodyAndHeaders("direct:send", body, camelEmailHeader);
> 
> The actual recipient address is specified in the camelEmailHeader.get("to")
> 
> The mail I send has the subject "Subject åäö ÅÄÖ" and the body "Body åäö
> ÅÄÖ"
> 
> There are still some problems, depending on which email client I use. 
> 
> Gmail: 
> The subject is displayed as "Subject: едц ЕДЦ"
> The body is displayed correctly
> 
> Thunderbird: 
> In the email list, the subject is displayed as "Subject: ??? ???"
> In the email itself, the subject displayed correctly
> The body is displayed as "Body åäö ÅÄÖ"
> 
> Apple mail:
> Both the subject and the body are displayed correctly
> 


Re: Email character encoding?

Posted by Mattias Severson <ma...@gmail.com>.
I created a new route which I added to my camel context:
from("direct:send").setProperty(Exchange.CHARSET_NAME, new
ConstantExpression("ISO-8859-1")).to("smtp://myserver");

And then I updated the producer template:
producerTemplate.sendBodyAndHeaders("direct:send", body, camelEmailHeader);

The actual recipient address is specified in the camelEmailHeader.get("to")

The mail I send has the subject "Subject åäö ÅÄÖ" and the body "Body åäö
ÅÄÖ"

There are still some problems, depending on which email client I use. 

Gmail: 
The subject is displayed as "Subject: едц ЕДЦ"
The body is displayed correctly

Thunderbird: 
In the email list, the subject is displayed as "Subject: ??? ???"
In the email itself, the subject displayed correctly
The body is displayed as "Body åäö ÅÄÖ"

Apple mail:
Both the subject and the body are displayed correctly

-- 
View this message in context: http://camel.465427.n5.nabble.com/Email-character-encoding-tp510814p511616.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Email character encoding?

Posted by Willem Jiang <wi...@gmail.com>.
Claus Ibsen wrote:
> On Fri, Jun 25, 2010 at 11:39 AM, Willem Jiang <wi...@gmail.com> wrote:
>> No, the charset property is set on the Exchange, you can't add it from the
>> message header.
>> You have to set it from a processor.
>>
> 
> There is a setProperty in the DSL you can use instead of the Processor

Oh, you can define a route to do that :)

from("direct:send").setProperty(Exchange.CHARSET_NAME, 
"ISO-8859-1").to(emailRecipientUri);

Then use below code to send the message

producerTemplate.sendBodyAndHeaders("direct:send", emailBody,
  camelEmailHeaders);

Willem

> 
> 
>> Willem
>>
>> Mattias Severson wrote:
>>> Thanks for the tip. I am currently on a "long-weekend" vacation, but I
>>> will
>>> try when I return to work.
>>> Do I have create a Process in order to set the Exhange.CHARSET_NAME on the
>>> exchange is i possible to take a shortcut and add it to the camel email
>>> headers directly, e.g.
>>>
>>> Map<String, Object> camelEmailHeaders = new HashMap<String, Object>();
>>> camelEmailHeaders.put(Exchange.CHARSET_NAME, "ISO-8859-1");
>>> // add more email headers...
>>> producerTemplate.sendBodyAndHeaders(emailRecipientUri, emailBody,
>>> camelEmailHeaders);
>>> /Mattias
>>
> 
> 
> 


Re: Email character encoding?

Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Jun 25, 2010 at 11:39 AM, Willem Jiang <wi...@gmail.com> wrote:
> No, the charset property is set on the Exchange, you can't add it from the
> message header.
> You have to set it from a processor.
>

There is a setProperty in the DSL you can use instead of the Processor


> Willem
>
> Mattias Severson wrote:
>>
>> Thanks for the tip. I am currently on a "long-weekend" vacation, but I
>> will
>> try when I return to work.
>> Do I have create a Process in order to set the Exhange.CHARSET_NAME on the
>> exchange is i possible to take a shortcut and add it to the camel email
>> headers directly, e.g.
>>
>> Map<String, Object> camelEmailHeaders = new HashMap<String, Object>();
>> camelEmailHeaders.put(Exchange.CHARSET_NAME, "ISO-8859-1");
>> // add more email headers...
>> producerTemplate.sendBodyAndHeaders(emailRecipientUri, emailBody,
>> camelEmailHeaders);
>> /Mattias
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Email character encoding?

Posted by Willem Jiang <wi...@gmail.com>.
No, the charset property is set on the Exchange, you can't add it from 
the message header.
You have to set it from a processor.

Willem

Mattias Severson wrote:
> Thanks for the tip. I am currently on a "long-weekend" vacation, but I will
> try when I return to work. 
> 
> Do I have create a Process in order to set the Exhange.CHARSET_NAME on the
> exchange is i possible to take a shortcut and add it to the camel email
> headers directly, e.g.
> 
> Map<String, Object> camelEmailHeaders = new HashMap<String, Object>();
> camelEmailHeaders.put(Exchange.CHARSET_NAME, "ISO-8859-1");
> // add more email headers...
> producerTemplate.sendBodyAndHeaders(emailRecipientUri, emailBody,
> camelEmailHeaders); 
> 
> /Mattias


Re: Email character encoding?

Posted by Mattias Severson <ma...@gmail.com>.
Thanks for the tip. I am currently on a "long-weekend" vacation, but I will
try when I return to work. 

Do I have create a Process in order to set the Exhange.CHARSET_NAME on the
exchange is i possible to take a shortcut and add it to the camel email
headers directly, e.g.

Map<String, Object> camelEmailHeaders = new HashMap<String, Object>();
camelEmailHeaders.put(Exchange.CHARSET_NAME, "ISO-8859-1");
// add more email headers...
producerTemplate.sendBodyAndHeaders(emailRecipientUri, emailBody,
camelEmailHeaders); 

/Mattias
-- 
View this message in context: http://camel.465427.n5.nabble.com/Email-character-encoding-tp510814p511274.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Email character encoding?

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Jun 23, 2010 at 8:16 AM, Mattias Severson <ma...@gmail.com> wrote:
>
> Hi,
>
> I am having trouble sending ISO-8859-1 characters, e.g. åäö, in emails. I
> have tried to set the defaultEncoding option of the
> http://camel.apache.org/mail.html Camel Mail  component to ISO-8859-1, but
> that did not solve the problem.

Where is the problem in the mail?
- the subject
- the mail body

And are you sending plain/txt mails or something like xml or html?

I assume you see the character problems using a mail client which
receives the email? eg Outlook or the likes?

You can enable some java mail debug (debugMode=true) and you should be
able to see the actual mail message being send to the mail server.


>
> The sender is implemented as
>
> producerTemplate.sendBodyAndHeaders(emailRecipientUri, emailBody,
> camelEmailHeaders);
>
> and I am using Camel 2.3.0
>
> Any ideas?
>
> /Mattias
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Email-character-encoding-tp510814p510814.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Email character encoding?

Posted by Mattias Severson <ma...@gmail.com>.
And there is more:

The 
http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/mail/javamail/MimeMessageHelper.html
MimeMessageHelper  gives more options to send both plain text and html
formatted mail in the same message (to support all kinds of email clients),
as well as inline content and email attachments:

MimeMessage message = mailSender.createMimeMessage();

// add recipient, sender and subject

 MimeMessageHelper helper = new MimeMessageHelper(message, true, charset);
 helper.setText(plainMessage, htmlMessage);
 helper.addInline("someImage", new ClassPathResource("img/someImage.jpg"));
 helper.addAttachment("document.pdf", new
ClassPathResource("doc/document.pdf"));

/Mattias

-- 
View this message in context: http://camel.465427.n5.nabble.com/Email-character-encoding-tp510814p511118.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Email character encoding?

Posted by Mattias Severson <ma...@gmail.com>.
Spring has a interface called 
http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/mail/javamail/JavaMailSender.html
JavaMailSender . With it one can create a 
http://java.sun.com/products/javamail/javadocs/javax/mail/internet/MimeMessage.html
MimeMessage  that allows charsets to be specified in conjunction with the
subject and the message:

MimeMessage mailMessage = mailSender.createMimeMessage();
mailMessage.setSubject("Email subject", "ISO-8859-1");
mailMessage.setText("This is the email message", "ISO-8859-1");

// add sender, receiver, etc

mailSender.sendMessage(mailMessage);
 
-- 
View this message in context: http://camel.465427.n5.nabble.com/Email-character-encoding-tp510814p511111.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Email character encoding?

Posted by Willem Jiang <wi...@gmail.com>.
Hi Mattias,

You don't need to encoding the subject yourself, you just need to set 
the charset name on the exchange, then camel-mail will take care of it.

Did you try out this code to send the subject ?

producerTemplate.send(emailRecipientUri, new Processor() {
    void process(Exchange exchange) throws Exception {
        exchange.getIn().setBody(emailBody);
        exchange.getIn().setHeaders(camelEmailHeaders);
        exchange.setProperty(Exchange.CHARSET_NAME, "ISO-8859-1");
    }
}

Willem
----------------------------------
Apache Camel, Apache CXF committer
Open SOA http://www.fusesource.com
Blog http://willemjiang.blogspot.com
Tiwtter http://twitter.com/willemjiang

Mattias Severson wrote:
> Yes, I also read about the US-ASCII encoding. 
> Consequently, I tried to use 
> http://java.sun.com/products/javamail/javadocs/javax/mail/internet/MimeUtility.html#encodeText%28java.lang.String,%20java.lang.String,%20java.lang.String%29
> MimeUtility.encodeText(...)  with "B" encoding to base 64 encode the
> message. The message is encoded, but the recipients are unable to decode it.
> 
> /Mattias


Re: Email character encoding?

Posted by Mattias Severson <ma...@gmail.com>.
Yes, I also read about the US-ASCII encoding. 
Consequently, I tried to use 
http://java.sun.com/products/javamail/javadocs/javax/mail/internet/MimeUtility.html#encodeText%28java.lang.String,%20java.lang.String,%20java.lang.String%29
MimeUtility.encodeText(...)  with "B" encoding to base 64 encode the
message. The message is encoded, but the recipients are unable to decode it.

/Mattias
-- 
View this message in context: http://camel.465427.n5.nabble.com/Email-character-encoding-tp510814p511108.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Email character encoding?

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Jun 24, 2010 at 3:37 PM, Willem Jiang <wi...@gmail.com> wrote:
> Claus Ibsen wrote:
>>
>> On Thu, Jun 24, 2010 at 2:52 PM, Willem Jiang <wi...@gmail.com>
>> wrote:
>>>
>>> Hi,
>>>
>>> I just check the Java document of MimeMessage[1], the message subject
>>> *must*
>>> contain only US-ASCII characters, maybe that cause your problem.
>>>
>>>
>>> [1]http://java.sun.com/products/javamail/javadocs/javax/mail/internet/MimeMessage.html
>>>
>>
>> Ah there is an overloaded setSubject which accepts a charset. Do we
>> use that in the camel-mail code?
>>
>
> Yes, we used it in camel 2.3, but I think there could be something wrong
> with getting the default charset from the exchange.
>

Ah yeah you change some code to fallback to use UTF-8 or JVM default
or something.
This may cause that issue?


>>
>>> Willem Jiang wrote:
>>>>
>>>> Mattias Severson wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>> I am having trouble sending ISO-8859-1 characters, e.g. едц, in emails.
>>>>> I
>>>>> have tried to set the defaultEncoding option of the
>>>>> http://camel.apache.org/mail.html Camel Mail  component to ISO-8859-1,
>>>>> but
>>>>> that did not solve the problem.
>>>>> The sender is implemented as
>>>>>
>>>>> producerTemplate.sendBodyAndHeaders(emailRecipientUri, emailBody,
>>>>> camelEmailHeaders);
>>>>
>>>> Maybe you need to set the Exchange.property for the charset like this
>>>>
>>>> producerTemplate.send(emailRecipientUri, new Processor() {
>>>>  void process(Exchange exchange) throws Exception {
>>>>      exchange.getIn().setBody(emailBody);
>>>>      exchange.getIn().setHeaders(camelEmailHeaders);
>>>>      exchange.setProperty(Exchange.CHARSET_NAME, "ISO-8859-1");
>>>>  }
>>>> }
>>>>
>>>> Willem
>>>> ----------------------------------
>>>> Apache Camel, Apache CXF committer
>>>> Open SOA http://www.fusesource.com
>>>> Blog http://willemjiang.blogspot.com
>>>> Tiwtter http://twitter.com/willemjiang
>>>>>
>>>>> and I am using Camel 2.3.0
>>>>>
>>>>>
>>>>> Any ideas?
>>>>>
>>>>> /Mattias
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
>>
>>
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Email character encoding?

Posted by Willem Jiang <wi...@gmail.com>.
Claus Ibsen wrote:
> On Thu, Jun 24, 2010 at 2:52 PM, Willem Jiang <wi...@gmail.com> wrote:
>> Hi,
>>
>> I just check the Java document of MimeMessage[1], the message subject *must*
>> contain only US-ASCII characters, maybe that cause your problem.
>>
>> [1]http://java.sun.com/products/javamail/javadocs/javax/mail/internet/MimeMessage.html
>>
> 
> Ah there is an overloaded setSubject which accepts a charset. Do we
> use that in the camel-mail code?
> 

Yes, we used it in camel 2.3, but I think there could be something wrong 
with getting the default charset from the exchange.

> 
>> Willem Jiang wrote:
>>> Mattias Severson wrote:
>>>> Hi,
>>>>
>>>> I am having trouble sending ISO-8859-1 characters, e.g. åäö, in emails. I
>>>> have tried to set the defaultEncoding option of the
>>>> http://camel.apache.org/mail.html Camel Mail  component to ISO-8859-1, but
>>>> that did not solve the problem.
>>>> The sender is implemented as
>>>>
>>>> producerTemplate.sendBodyAndHeaders(emailRecipientUri, emailBody,
>>>> camelEmailHeaders);
>>> Maybe you need to set the Exchange.property for the charset like this
>>>
>>> producerTemplate.send(emailRecipientUri, new Processor() {
>>>   void process(Exchange exchange) throws Exception {
>>>       exchange.getIn().setBody(emailBody);
>>>       exchange.getIn().setHeaders(camelEmailHeaders);
>>>       exchange.setProperty(Exchange.CHARSET_NAME, "ISO-8859-1");
>>>   }
>>> }
>>>
>>> Willem
>>> ----------------------------------
>>> Apache Camel, Apache CXF committer
>>> Open SOA http://www.fusesource.com
>>> Blog http://willemjiang.blogspot.com
>>> Tiwtter http://twitter.com/willemjiang
>>>> and I am using Camel 2.3.0
>>>>
>>>>
>>>> Any ideas?
>>>>
>>>> /Mattias
>>>>
>>>>
>>>>
>>>>
>>>
>>
> 
> 
> 


Re: Email character encoding?

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Jun 24, 2010 at 2:52 PM, Willem Jiang <wi...@gmail.com> wrote:
> Hi,
>
> I just check the Java document of MimeMessage[1], the message subject *must*
> contain only US-ASCII characters, maybe that cause your problem.
>
> [1]http://java.sun.com/products/javamail/javadocs/javax/mail/internet/MimeMessage.html
>

Ah there is an overloaded setSubject which accepts a charset. Do we
use that in the camel-mail code?


> Willem Jiang wrote:
>>
>> Mattias Severson wrote:
>>>
>>> Hi,
>>>
>>> I am having trouble sending ISO-8859-1 characters, e.g. åäö, in emails. I
>>> have tried to set the defaultEncoding option of the
>>> http://camel.apache.org/mail.html Camel Mail  component to ISO-8859-1, but
>>> that did not solve the problem.
>>> The sender is implemented as
>>>
>>> producerTemplate.sendBodyAndHeaders(emailRecipientUri, emailBody,
>>> camelEmailHeaders);
>>
>> Maybe you need to set the Exchange.property for the charset like this
>>
>> producerTemplate.send(emailRecipientUri, new Processor() {
>>   void process(Exchange exchange) throws Exception {
>>       exchange.getIn().setBody(emailBody);
>>       exchange.getIn().setHeaders(camelEmailHeaders);
>>       exchange.setProperty(Exchange.CHARSET_NAME, "ISO-8859-1");
>>   }
>> }
>>
>> Willem
>> ----------------------------------
>> Apache Camel, Apache CXF committer
>> Open SOA http://www.fusesource.com
>> Blog http://willemjiang.blogspot.com
>> Tiwtter http://twitter.com/willemjiang
>>>
>>> and I am using Camel 2.3.0
>>>
>>>
>>> Any ideas?
>>>
>>> /Mattias
>>>
>>>
>>>
>>>
>>
>>
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Email character encoding?

Posted by Willem Jiang <wi...@gmail.com>.
Hi,

I just check the Java document of MimeMessage[1], the message subject 
*must* contain only US-ASCII characters, maybe that cause your problem.

[1]http://java.sun.com/products/javamail/javadocs/javax/mail/internet/MimeMessage.html

Willem Jiang wrote:
> Mattias Severson wrote:
>> Hi,
>>
>> I am having trouble sending ISO-8859-1 characters, e.g. åäö, in emails. I
>> have tried to set the defaultEncoding option of the 
>> http://camel.apache.org/mail.html Camel Mail  component to ISO-8859-1, 
>> but
>> that did not solve the problem.
>> The sender is implemented as
>>
>> producerTemplate.sendBodyAndHeaders(emailRecipientUri, emailBody,
>> camelEmailHeaders);
> 
> Maybe you need to set the Exchange.property for the charset like this
> 
> producerTemplate.send(emailRecipientUri, new Processor() {
>    void process(Exchange exchange) throws Exception {
>        exchange.getIn().setBody(emailBody);
>        exchange.getIn().setHeaders(camelEmailHeaders);
>        exchange.setProperty(Exchange.CHARSET_NAME, "ISO-8859-1");
>    }
> }
> 
> Willem
> ----------------------------------
> Apache Camel, Apache CXF committer
> Open SOA http://www.fusesource.com
> Blog http://willemjiang.blogspot.com
> Tiwtter http://twitter.com/willemjiang
>>
>> and I am using Camel 2.3.0
>>
>>
>> Any ideas?
>>
>> /Mattias
>>
>>
>>
>>
> 
> 


Re: Email character encoding?

Posted by Willem Jiang <wi...@gmail.com>.
Mattias Severson wrote:
> Hi,
> 
> I am having trouble sending ISO-8859-1 characters, e.g. åäö, in emails. I
> have tried to set the defaultEncoding option of the 
> http://camel.apache.org/mail.html Camel Mail  component to ISO-8859-1, but
> that did not solve the problem. 
> 
> The sender is implemented as
> 
> producerTemplate.sendBodyAndHeaders(emailRecipientUri, emailBody,
> camelEmailHeaders);

Maybe you need to set the Exchange.property for the charset like this

producerTemplate.send(emailRecipientUri, new Processor() {
    void process(Exchange exchange) throws Exception {
        exchange.getIn().setBody(emailBody);
        exchange.getIn().setHeaders(camelEmailHeaders);
        exchange.setProperty(Exchange.CHARSET_NAME, "ISO-8859-1");
    }
}

Willem
----------------------------------
Apache Camel, Apache CXF committer
Open SOA http://www.fusesource.com
Blog http://willemjiang.blogspot.com
Tiwtter http://twitter.com/willemjiang
> 
> and I am using Camel 2.3.0
> 
> 
> Any ideas?
> 
> /Mattias
> 
> 
> 
>