L
Lee
Hi there,
This looks like a frequently asked question, but none of the answers I
found with a Google search seem to help. I have a class that send email
messages, but when I send attachements I encounter problems. Plain text
files just appear in the message body, where as image files appear as
"gobbeldygook" (character encoding/whatever).
Does anyone use javax.mail frequently? Can you enlighten me as to what
my problem is? Snippets below:
-------------------------
msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
msg.setSubject(subject);
msg.setSentDate(new Date());
msg.setRecipients(MimeMessage.RecipientType.TO, addressList);
MimeBodyPart mbp1 = new MimeBodyPart();
mbp1.setText(messageBody, "us-ascii");
MimeMultipart mp = new MimeMultipart();
mp.addBodyPart(mbp1);
if...
{
for...
{
MimeBodyPart mbp2 = new MimeBodyPart();
ataSource source = new FileDataSource(attArr);
mbp2.setDataHandler(new DataHandler(source));
mbp2.setFileName(attArr);
mp.addBodyPart(mbp2);
}
}
msg.setContent(mp);
----------------------------
This looks like a frequently asked question, but none of the answers I
found with a Google search seem to help. I have a class that send email
messages, but when I send attachements I encounter problems. Plain text
files just appear in the message body, where as image files appear as
"gobbeldygook" (character encoding/whatever).
Does anyone use javax.mail frequently? Can you enlighten me as to what
my problem is? Snippets below:
-------------------------
msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
msg.setSubject(subject);
msg.setSentDate(new Date());
msg.setRecipients(MimeMessage.RecipientType.TO, addressList);
MimeBodyPart mbp1 = new MimeBodyPart();
mbp1.setText(messageBody, "us-ascii");
MimeMultipart mp = new MimeMultipart();
mp.addBodyPart(mbp1);
if...
{
for...
{
MimeBodyPart mbp2 = new MimeBodyPart();
ataSource source = new FileDataSource(attArr);
mbp2.setDataHandler(new DataHandler(source));
mbp2.setFileName(attArr);
mp.addBodyPart(mbp2);
}
}
msg.setContent(mp);
----------------------------