Cant get images as attachment....
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Rajiv_M
Posted On:   Monday, May 14, 2001 03:08 AM

I tried to read attachments using JavaMail 1.2. See code snippet below.While i could read applicatio/octet-stream files i get a null value for file name for image/.... type files. //Code MimeBodyPart bp = (MimeBodyPart) mp.getBodyPart(i); ContentType ct = new ContentType(bp.getContentType()); ed_message.setContentType("text/html"); if ("application/octet-stream".equalsIgnoreCase(ct.getBaseType())) { MimePartDataSource d = (MimePartDataSource)bp.getDataHandler().getDataSource(); String msg = "This mail has attachment. Press Attachments button to save it. "; JOptionPane.showMessageDialog(null,msg+"Attachment: "+d.getName()); b_rdattach.   More>>

I tried to read attachments using JavaMail 1.2. See code snippet below.While i could read applicatio/octet-stream files i get a null value for file name for image/.... type files.

//Code
MimeBodyPart bp = (MimeBodyPart) mp.getBodyPart(i);
ContentType ct = new ContentType(bp.getContentType());
ed_message.setContentType("text/html");
if ("application/octet-stream".equalsIgnoreCase(ct.getBaseType()))
{
MimePartDataSource d = (MimePartDataSource)bp.getDataHandler().getDataSource();
String msg = "This mail has attachment. Press Attachments button to save it.
";
JOptionPane.showMessageDialog(null,msg+"Attachment: "+d.getName());
b_rdattach.setEnabled(true);
b_rdattach.requestFocus();
}
if ("image/gif".equalsIgnoreCase(ct.getBaseType())||"image/jpeg".equalsIgnoreCase(ct.getBaseType()))
{
MimePartDataSource d = (MimePartDataSource)bp.getDataHandler().getDataSource();
System.out.println(d.getName());
showPics(d.getName()); //Display image in a JTextPane
}
s+=bp.getContent(); //Store text/html content in a String
//

The first if stt returns a file name
the second gives null !

Help !!!!!!!!!

   <<Less

Re: Cant get images as attachment....

Posted By:   kunwar_manish  
Posted On:   Tuesday, May 15, 2001 01:56 AM

You can send imaage as attachment
About | Sitemap | Contact