Free Support Forum -

How do I know Attachment is a msg/eml without its extension?


How I can know attachment is msg/eml without the use of its extension property.

mapiMsg = MapiMessage.fromStream(inputStream);
final MapiAttachmentCollection collAttchmnt = mapiMsg.getAttachments();
logger.debug("[0MS001] Attachment Size : ["+collAttchmnt.size()+"]");

for (int temp = 0; temp < collAttchmnt.size(); temp++) {

final MapiAttachment attchmnt = (MapiAttachment) collAttchmnt

//attchmnt object is type of eml/msg?



Hi sachin,

We are sorry for the delayed response.

We are analyzing the issue and will let you know soon about our findings.

Your patience and understanding is highly appreciated.

Hi Sachin,

I am afraid to inform that MapiMessage does not provide identification for attachments.

However if you load the mail message using MailMessage then attachment’s “media type” can be used the identify the MSG attachment. Media type contains string value “message/rfc822” for the MSG type attachments.

Please give a try to the following code and let us know your feedback.

MailMessage mailMsg = MailMessage.load(“SampleWithAttachments.msg”);
final AttachmentCollection collAttchmnt = mailMsg.getAttachments();
for (int temp = 0; temp < collAttchmnt.size(); temp++)
final Attachment attchmnt = (Attachment)collAttchmnt.get(temp);
System.out.print(“MSG file”);
System.out.print(“Not a MSG file”);