Getting the message attachments

Top  Previous  Next

You may retrieve any attachments for an email message using the EmailMessage#getAttachments method.  This will return a java.util.Enumeration of com.jscape.inet.mime.Attachment.

 

Example

 

// get all attachments

Enumeration atts = message.getAttachments();

                 

// loop thru attachments and write each to disk

while(atts.hasMoreElements()) {

 Attachment att = (Attachment)atts.nextElement();

 FileOutputStream fout = new FileOutputStream(new File(att.getFilename()));

 fout.write(att.getBodyData());

 fout.close();                                

}

 

 

 





Home | Company | Products | Solutions | Purchase | Support | Services | Blog

© 2021 JSCAPE LLC