• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Simple Text based Email : Problem with Russian Characters

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
My post is regarding sending Email with org.apache.commons.mail.Email.
I am using both Text based and Html based Emails.

I read properties file for Russian characters (converted to \uXXXX format) to build my body of the mail.

The problem is body of the mail displays ??? in Text mails but displays perfectly in HTML mail.

Is there any solution to rectify this. Any special setting to be made in Text based mails.

Thanks in Advance for replying.

Best Regards,
Bala
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello "Bala Kr"
Welcome to JavaRanch

We are glad to have you here. We have a naming policy at JavaRanch. Your displayed name must consist of a first name (or an initial), a space, and a family name (in that order) and not be obviously fictitious. Please take a moment to change it, which you can do right here.
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now coming to your question, the SimpleEmail class has a method setCharset where you can specify the charset for the message content. Try using that method.
 
Balasubramanian Krishnaswamy
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jai,
Thanks for replying. Please find the below code snippet which I am using.

public void sendTextEmail() throws EmailSendingException {
SimpleEmail email = new SimpleEmail();
setupEmail(email);
email.setCharset("UTF-8");
email.setSubject(subject);
email.setMsg(textBody);
email.send();
}

Also in my properties file I am saving the values as \uXXXX for each key (by using the nativeToascii.exe in ..//jdk/bin folder).

But the strange thing is the subject gets printed correctly but the Mail body goes for a toss (prints ???).

I also tried one more thing, keeping the .properties file content same, I included a line of code before sending the mail.

email.setContent(textBody, "text/plain; charset= UTF-8");

This modification makes the Mail body to display correctly, but the Subject displays as "???".

Then I tried to do something similar to my subject Strng variable.

email.setContent(subject, "text/plain; charset= UTF-8");

But this time it prints some Junk characters in subject (Mail body is ok).

I am totally confused :-( . Please Help me.

Best Regards,
Bala
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bala, thanks for changing your display name to conform to our naming policy.
As for the issue that you are seeing, try the following.
Just an example:



See if it works.
 
Balasubramanian Krishnaswamy
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jai,
Thanks for providing the code. This is already used in my Java Program. But still I tried your code.

The subject still appears as ??? :-(.

Any other idea to resolve this?

Best Regards,
Bala
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Balasubramanian Krishnaswamy:
Hi Jai,
Thanks for providing the code. This is already used in my Java Program. But still I tried your code.

The subject still appears as ??? :-(.

Any other idea to resolve this?

Best Regards,
Bala


What are you using to view the email? Can this application render Russian characters?
 
Balasubramanian Krishnaswamy
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using Microsoft outlook to view the Email messages triggered from my application.

The problem is my Mail body prints the Russian characters correctly in Text Based mail, but the Mail subject prints "???"

HTML based mail prints both Subject and Body of the mail correctly.

Best Regards,
Bala
 
Balasubramanian Krishnaswamy
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jai,
Were you able to find out some solution for the above issue?
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bala,

Sorry i dont have an answer as to why the subject is not showing up with the right charset. However, i do see similar (if not the same) issues being reported in the Bugzill of Apache Commons Mail Project. I would suggest, you subscribe to their users mailing list and see if any folks from the project can help you out.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic