diff --git a/src/scratchpad/src/org/apache/poi/hsmf/datatypes/AttachmentChunks.java b/src/scratchpad/src/org/apache/poi/hsmf/datatypes/AttachmentChunks.java index af2ea642a..55f8a5f25 100644 --- a/src/scratchpad/src/org/apache/poi/hsmf/datatypes/AttachmentChunks.java +++ b/src/scratchpad/src/org/apache/poi/hsmf/datatypes/AttachmentChunks.java @@ -31,10 +31,13 @@ import static org.apache.poi.hsmf.datatypes.MAPIProperty.ATTACH_MIME_TAG; import static org.apache.poi.hsmf.datatypes.MAPIProperty.ATTACH_RENDERING; import static org.apache.poi.hsmf.datatypes.MAPIProperty.ATTACH_SIZE; +import java.io.IOException; import java.util.ArrayList; import java.util.Comparator; import java.util.List; +import org.apache.poi.hsmf.MAPIMessage; + /** * Collection of convenence chunks for standard parts of the MSG file attachment. */ @@ -68,6 +71,36 @@ public class AttachmentChunks implements ChunkGroup { this.poifsName = poifsName; } + + /** + * Is this Attachment an embedded MAPI message? + */ + public boolean isEmbeddedMessage() { + return (attachmentDirectory != null); + } + /** + * Returns the embedded MAPI message, if the attachment + * is an embedded message, or null otherwise + */ + public MAPIMessage getEmbeddedMessage() throws IOException { + if (attachmentDirectory != null) { + return attachmentDirectory.getAsEmbededMessage(); + } + return null; + } + + /** + * Returns the embedded object, if the attachment is an + * object based embedding (image, document etc), or null + * if it's an embedded message + */ + public byte[] getEmbeddedAttachmentObject() { + if (attachData != null) { + return attachData.getValue(); + } + return null; + } + public Chunk[] getAll() { return allChunks.toArray(new Chunk[allChunks.size()]); }