problem when using special characters in mail
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Aditi_Sanghi
Posted On:   Monday, November 17, 2003 09:45 PM

hi,
i am using java mail API for sending mails from my application to any account. the problem is when i use special characters (eg quotes) in the content of my mail they are displayed as question marks in the mail.
Pls help me solve this problem.

Re: problem when using special characters in mail

Posted By:   Eric_Maginniss  
Posted On:   Tuesday, November 18, 2003 07:36 AM

This is a problem of encoding. When you create a MimePart to add to your mail, you need to set the content header type. Try this:


Message msg = new javax.mail.internet.MimeMessage(session);
MimeMultipart mp = new MimeMultipart("alternative");
MimeBodyPart textPart = new MimeBodyPart();
textPart.setText(text);
textPart.setHeader("Content-Type", "text/plain; charset=ISO_8859-1");
mp.addBodyPart(textPart);
msg.setContent(mp);
About | Sitemap | Contact