Free Support Forum - aspose.com

Embedded Images coming as Attachement

Hi,

We have a requirement for which we are extracting attachments from a Outlook Mail File (.msg) using a licensed version of Aspose . During extraction we are getting embeded images in msg as attachments which we do not require. Can you please help us in this.

Hi,

Thank you for inquiry.

Could you please specify which version and platform (.NET/Java) of Aspose.Network are you using? Please also post the sample MSG file for our analysis.

Hi,

Thank You for your quick reply.

We are using JAVA platform.I have attached the sample EMBEDED IMAGE CHECK.msg , in this file there is an embeded image and one attached document. But while extracting the attachment instead of getting only one attachment HP23092011.pptx i am also getting embeded image image001.jpg as attachment.

Used Code :-

tempFilePath="C:\AsposeTest";
fileName="EMBEDED IMAGE CHECK.msg";

MapiMessage outlookMessageFile = MapiMessage
.fromFile(tempFilePath + fileName);
MapiAttachmentCollection attColl = outlookMessageFile
.getAttachments();
int index=0
Iterator iter = attColl.iterator();

while (iter.hasNext()) {
MapiAttachment outlookMessageAttachment = iter.next();
MapiAttachment attachment = (MapiAttachment) attColl
.get(index);

attachment.save(tempFilePath+ outlookMessageAttachment.getLongFileName());
index++
}

Hi,

Thanks for posting the sample file.

Please update your code as follows to detect the embedded and regular attachments.

MapiAttachment attachment = (MapiAttachment) attColl.get(index);
if (attachment.getProperties().contains(0x3712001E) || attachment.getProperties().contains(0x3712001F))
{
System.out.println("Embedded attachment: " + outlookMessageAttachment.getLongFileName());
attachment.save(strBaseFolder+ outlookMessageAttachment.getLongFileName());
}
else
{
System.out.println("Regular attachment: " + outlookMessageAttachment.getLongFileName());
attachment.save(strBaseFolder+ outlookMessageAttachment.getLongFileName());
}

Hi,

This did not work.

I am getting again both actual and embedded attachment in "else" part.

I did not get the API attachment.getProperties().contains instead i used attachment.getProperties().containsValue. We are using Aspose Network 2.0.1-jdk15.jar .Can you please let us know if any change is required.

Hi,

Please use the latest version of Aspose.Network for Java 2.3 to get this working.