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.

