Image doesn't show on email

I am attempting to send emails with combinations of text and image/png. The image is a page of a report that is formatted using grid baglayout within a JPanel. I receive an email but when I attempt to send the image alone or the image with the text nothing appears in the body of the email message. When I send just the text it appears correctly within the body of the email. I am recieving email from other sources that appears to be combinations of text and image. My code a substantial. What follows is the relevant code only.

JPanel jpanel;

privatebyte [] ReportIn;

BufferedImage MailImage =new BufferedImage(600, ((PageObject)(pages.get(0))).getPageHeight(), BufferedImage.TYPE_INT_RGB);

Graphics g2d = MailImage.createGraphics();

jpanel.paint(g2d);

ByteArrayOutputStream ReportImageFile =new ByteArrayOutputStream();

try{

ImageIO.write(MailImage,"png", ReportImageFile);

ReportIn = ReportImageFile.toByteArray();

}

catch (IOException ew){

}

try

{

Authenticator auth =new SmtpAuthenticator(from, pword);

Session session = Session.getInstance(props, auth);

//session.setDebug(true);

MimeMessage msg =new MimeMessage(session);

String DataID =new Date().toString();

msg.setSubject(m_subject);

msg.setFrom(new InternetAddress(d_email));

msg.addRecipient(Message.RecipientType.TO,new InternetAddress(m_to));

msg.setHeader("Content-Type","multipart/mixed");

MimeMultipart mp =new MimeMultipart("related");

MimeBodyPart mbp1 =new MimeBodyPart();

DataSource ds =new ByteArrayDataSource(ReportIn,"image/png");

mbp1.setDataHandler(new DataHandler(ds));

mbp1.setContentID(DataID);

mp.addBodyPart(mbp1);

MimeBodyPart mbp2 =new MimeBodyPart();

mbp2.setText("test2");

mbp2.setContentID(DataID);

mp.addBodyPart(mbp2);

msg.setContent(mp);

System.out.println(mp.getCount());

System.out.println( mbp1.getLineCount());

//System.out.println( mbp1.getHeader());

Transport.send(msg);

}

catch (Exception mex)

{

mex.printStackTrace();

}

Any suggestions would be appreciated.

[3259 byte] By [sandyg9000a] at [2007-11-27 7:05:16]
# 1

You're creating a multipart/related message. Normally the first part will be an

html part that references the images in the other parts, yet you've put the text

in the second part and the text doesn't reference the image. You've also given

both of your parts the same Content-ID.

This example might help you:

http://java.sun.com/developer/EJTechTips/2004/tt0625.html

bshannona at 2007-7-12 18:56:37 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...