|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
com.mirrorworlds.lifestreams.mail.tnef.internet.TnefMultipart
The TnefMultipart class is an implementation of the abstract Multipart class (in the Java MAIL api) that uses MIME conventions for the multipart data.
Note: This package is still at a very early stage. Requires the Java Mail API and the Java Activation Framework API.
Sample usage (hack) with Java Mail API:
// assume you have Java Mail API MultiPart object that has text/plain message // as well as an application/ms-tnef attachment (bodypart). // The solution (hack) described here basically removes this bodypart from the // multipart, then obtains the tnef attachments from this application/ms-tnef // bodypart and adds these attachments back into the original multipart object. // (ideally, all of these should be transparent to the Java Mail API user, // probably by associating a DataContentHandler etc.(JAF) for the tnef content-type). // mp is of type Multipart that has the application/ms-tnef attachment. // loop thru and get the tnef part. int size = mp.getCount(); boolean done = false; for (int i = 0; i < size; i++) { BodyPart bp = mp.getBodyPart(i); // ct is content-type of the body part. String ct = bp.getContentType(); //if this is a tnef, then process it. if (ct.indexOf("application/ms-tnef") != -1) { // create tnef data source. TnefMultipartDataSource tnefDS = new TnefMultipartDataSource((MimePart)bp); // create Tnef multipart MimeMultipart tnefMP = new TnefMultipart(tnefDS); // get num of tnef attachments int partCount = tnefMP.getCount(); // loop thru and add the attachment into the original multipart. for (int k = 0; k < partCount; k++) { BodyPart tnefBodyPart = tnefMP.getBodyPart(k); mp.addBodyPart(tnefBodyPart); } //remove the original application/ms-tnef part. mp.removeBodyPart(bp); bp = null; done = true; break; }// if }//for
Constructor Summary | |
TnefMultipart()
Default constructor. |
|
TnefMultipart(TnefMultipartDataSource ds)
Constructs a TnefMultipart object and its bodyparts from the given DataSource. |
Constructor Detail |
public TnefMultipart()
contentType
field. MimeBodyParts may be added later.
public TnefMultipart(TnefMultipartDataSource ds) throws com.mirrorworlds.lifestreams.mail.tnef.internet.MessagingException
ds
- TnefMultipartDataSource.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |