Send mail with israelian text

G

giugy

Hi, sorry for my english but i don't speak it very well....i have a
problem with my class that send email....

I need to send email with attachments and with subject and body in
israelian (hebrew), and Content-Transfer-Encoding = 8bit...i have some
problem with this....i try to set the message's header with the
charset for hebrew
message.setHeader("Content-Type", "text/plain; charset=ISO-8859-8");
and to set the message's Content-Transfer-Encoding
message.addHeader("Content-Transfer-Encoding", "8bit");

This is my code

import javax.mail.BodyPart;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.SendFailedException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.*;
import javax.activation.*;

........

Properties props = System.getProperties();
// Setup mail server
props.put("mail.smtp.host", smtpHost);
props.put("mail.smtp.password", password);
props.put("mail.smtp.user", userId);

props.put("mail.mime.charset", "ISO-8859-8");
props.put("user.language", "iw");
props.put("sun.jnu.encoding", "ISO-8859-8");
props.put("file.encoding", "ISO-8859-8");

Session session = Session.getDefaultInstance(props, null);

MimeMessage message = new MimeMessage(session);

message.setFrom(new InternetAddress(from));
java.util.StringTokenizer tokenizer = new
java.util.StringTokenizer(to,";");
while (tokenizer.hasMoreTokens()){
message.addRecipient(Message.RecipientType.TO,new
InternetAddress(tokenizer.nextToken()));
}
message.setSubject(subject);

if(copy != null){
java.util.StringTokenizer copyTokenizer = new
java.util.StringTokenizer(copy,";");
while (copyTokenizer.hasMoreTokens()){
message.addRecipient(Message.RecipientType.CC,new
InternetAddress(copyTokenizer.nextToken()));
}
}
// Create the multi-part
Multipart multipart = new MimeMultipart();
BodyPart messageBodyPart = new MimeBodyPart();

messageBodyPart.setText(body);
multipart.addBodyPart(messageBodyPart);
DataSource dataSource;
int index = 0;
if(attaches != null){
for(int i = 0; i < attaches.size(); i++){
messageBodyPart = new MimeBodyPart();
String attach = attaches.get(index).toString();
String attachName = new String();
if(asAttach != null)
attachName = asAttach.get(index).toString();
else
attachName = new java.io.File(attachName).getName();
dataSource = new FileDataSource(attach);
messageBodyPart.setDataHandler(new DataHandler(dataSource));
messageBodyPart.setFileName(attachName);
// Add parts
multipart.addBodyPart(messageBodyPart);
//messageBodyPart = new MimeBodyPart();
++index;
}
}
// Put parts in message
message.setContent(multipart);
message.setHeader("Content-Type", "text/plain;
charset=ISO-8859-8");
message.saveChanges();
message.addHeader("Content-Transfer-Encoding", "8bit");

Transport.send(message);




The problem is that with this code the class doesn't work
fine....infact I receive an email without attachemts, not in hebrew
language and with this body

------=_Part_0_26210109.1212049275627
Content-Type: text/plain; charset=ISO-8859-8
Content-Transfer-Encoding: quoted-printable

BODY TEXT

------=_Part_0_26210109.1212049275627
Content-Type: text/plain; charset=ISO-8859-8; name=debug1.txt
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=debug1.txt

Hello this is attachment test 1
Text present in tha attachment 1

------=_Part_0_26210109.1212049275627
Content-Type: text/plain; charset=us-ascii; name=Z.txt
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=Z.txt

Hello this is attachment test 2
Text present in the attachment 2

------=_Part_0_26210109.1212049275627--


Just for information..from a test that i have done i see that if I use

message.setHeader("Content-Type", "text/xml; charset=ISO-8859-8");

and not

message.setHeader("Content-Type", "text/plain; charset=ISO-8859-8");

the email is incorrect (infact i receive an email without body and
with an .xml as attachments)
but the charset is correct...infact when i try to open the email
Outlook say me that i need to install the support for hebrew (this is
on my Windows machine....i need to use this on a unix machine with
hebrew as default) ..... why with text/plain no, and with text/xml
yes????

How i can do so that this class send me an email with the correct
attachments and with the correct charset for the hebrew????

Thanks for help.bye
 
G

GArlington

Hi, sorry for my english but i don't speak it very well....i have a
problem with my class that send email....

I need to send email with attachments and with subject and body in
israelian (hebrew), and Content-Transfer-Encoding = 8bit...i have some
problem with this....i try to set the message's header with the
charset for hebrew
message.setHeader("Content-Type", "text/plain; charset=ISO-8859-8");
and to set the message's Content-Transfer-Encoding
message.addHeader("Content-Transfer-Encoding", "8bit");

This is my code

import javax.mail.BodyPart;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.SendFailedException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.*;
import javax.activation.*;

.......

Properties props = System.getProperties();
// Setup mail server
props.put("mail.smtp.host", smtpHost);
props.put("mail.smtp.password", password);
props.put("mail.smtp.user", userId);

props.put("mail.mime.charset", "ISO-8859-8");
props.put("user.language", "iw");
props.put("sun.jnu.encoding", "ISO-8859-8");
props.put("file.encoding", "ISO-8859-8");

Session session = Session.getDefaultInstance(props, null);

MimeMessage message = new MimeMessage(session);

message.setFrom(new InternetAddress(from));
java.util.StringTokenizer tokenizer = new
java.util.StringTokenizer(to,";");
while (tokenizer.hasMoreTokens()){
message.addRecipient(Message.RecipientType.TO,new
InternetAddress(tokenizer.nextToken()));
}
message.setSubject(subject);

if(copy != null){
java.util.StringTokenizer copyTokenizer = new
java.util.StringTokenizer(copy,";");
while (copyTokenizer.hasMoreTokens()){
message.addRecipient(Message.RecipientType.CC,new
InternetAddress(copyTokenizer.nextToken()));
}
}
// Create the multi-part
Multipart multipart = new MimeMultipart();
BodyPart messageBodyPart = new MimeBodyPart();

messageBodyPart.setText(body);
multipart.addBodyPart(messageBodyPart);
DataSource dataSource;
int index = 0;
if(attaches != null){
for(int i = 0; i < attaches.size(); i++){
messageBodyPart = new MimeBodyPart();
String attach = attaches.get(index).toString();
String attachName = new String();
if(asAttach != null)
attachName = asAttach.get(index).toString();
else
attachName = new java.io.File(attachName).getName();
dataSource = new FileDataSource(attach);
messageBodyPart.setDataHandler(new DataHandler(dataSource));
messageBodyPart.setFileName(attachName);
// Add parts
multipart.addBodyPart(messageBodyPart);
//messageBodyPart = new MimeBodyPart();
++index;
}
}
// Put parts in message
message.setContent(multipart);
message.setHeader("Content-Type", "text/plain;
charset=ISO-8859-8");
message.saveChanges();
message.addHeader("Content-Transfer-Encoding", "8bit");

Transport.send(message);

The problem is that with this code the class doesn't work
fine....infact I receive an email without attachemts, not in hebrew
language and with this body

------=_Part_0_26210109.1212049275627
Content-Type: text/plain; charset=ISO-8859-8
Content-Transfer-Encoding: quoted-printable

BODY TEXT

------=_Part_0_26210109.1212049275627
Content-Type: text/plain; charset=ISO-8859-8; name=debug1.txt
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=debug1.txt

Hello this is attachment test 1
Text present in tha attachment 1

------=_Part_0_26210109.1212049275627
Content-Type: text/plain; charset=us-ascii; name=Z.txt
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=Z.txt

Hello this is attachment test 2
Text present in the attachment 2

------=_Part_0_26210109.1212049275627--

Just for information..from a test that i have done i see that if I use

message.setHeader("Content-Type", "text/xml; charset=ISO-8859-8");

and not

message.setHeader("Content-Type", "text/plain; charset=ISO-8859-8");

the email is incorrect (infact i receive an email without body and
with an .xml as attachments)
but the charset is correct...infact when i try to open the email
Outlook say me that i need to install the support for hebrew (this is
on my Windows machine....i need to use this on a unix machine with
hebrew as default) ..... why with text/plain no, and with text/xml
yes????

How i can do so that this class send me an email with the correct
attachments and with the correct charset for the hebrew????

Thanks for help.bye

Why not try "charset=utf-8"?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,781
Messages
2,569,615
Members
45,297
Latest member
EngineerD

Latest Threads

Top