Monika Sach

Greenhorn
+ Follow
since Mar 07, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Monika Sach

Hi

I am generating a report by picking user profiles from the OID. The OID contains special turkish characters. When I write them on the browser the characters seem fine.
But I need to export them to excel in the application. When I do so these characters get screwed up.
I have seen a related post where it was suggested to use HTML instead of ms-excel.
I need to write them to an excel. Is it possible? If yes, how?

I have tried all stuff like:
request.setCharacterEncoding("UTF-8");
response.setContentType("application/vnd.ms-excel";"charset=UTF-8");
response.setHeader(Defs.CONTENT_DISPOSITION, Defs.ATTACHMENT + "=\"Report.xls\"");
// Get an instance of the Writer.
out = response.getWriter();

Thanks
M
17 years ago
Hi

I am trying to send emails with 1)plain text and 2)html .

My problem is while sending html emails if I have some special character say (ź , this character gets screwed up. This character is what the user inputs in a jsp, so is generated dynamically. With plain text its fine.

I use the below code for plain text it:
Properties props = System.getProperties();

// -- Attaching to default Session, or we could start a new one --

props.put("mail.smtp.host", smtpServer);
props.put("mail.mime.charset","UTF-8");
Session session = Session.getDefaultInstance(props, null);

// -- Create a new message --
Message msg = new MimeMessage(session);

// -- Set the FROM and TO fields --
msg.setFrom(new InternetAddress(from));
msg.setRecipients(Message.RecipientType.TO,
InternetAddress.parse(to, false));

// -- We could include CC recipients too --
// if (cc != null)
// msg.setRecipients(Message.RecipientType.CC
// ,InternetAddress.parse(cc, false));

// -- Set the subject and body text --
msg.setSubject(subject);
msg.setText(body);


// -- Send the message --
Transport.send(msg);

For HTML I just comment
props.put("mail.mime.charset","UTF-8");

and instead of
msg.setText(body);
I use
msg.setDataHandler(new DataHandler(new ByteArrayDataSource(strMessageBody,"text/html")));

Am I doing something wrong for HTML? Whats the correct way for it

Thanks
M
17 years ago