How to extract a .eml (e-mail file) "attachment" from an e-mail
843830Mar 27 2006 — edited Jul 25 2008Hi,
I have a slight problem with e-mail attachments. It's quite an explanation, so stick with me please.
I have to extend, debug and adapt an e-mail archive for my company.
I already worked on this project for 2 months, to make an extra batch and change some functionality of the existing e-mail archive.
I've been outsourced for a montsh, and now back on the e-mail archive.
There were some problems with e-mail attachments. (.gif, .doc, ...)
Some of them weren't shown in the web application.
The code that already has been written has a custom Email object. This e-mail object contains custom EmailBodyPart objects. Every EmailBodyPart has a disposition (Part.INLINE or Part.ATTACHMENT).
In every JavaMail Message object, every BodyPart is read, the disposition is extracted, and an EmailBodyPart is created with the disposition and some other data. Then, this EmailBodyPart is added to the Email object.
But sometimes, an attachment (.gif, .doc, ...) doesn't have the correct disposition in a Message, and isn't added as attachment, but as INLINE.
This way, in the web application, there aren't any attachments visible for the e-mail, but when you send the mail back to your inbox through the web interface, you can see the attachments again.
I had to solve this, and make the attachments visible in the web interface, and i did. I just checked if a filename was present, and if it wasn't an image (images still can be inline), then the disposition of the EmailBodyPart is set to Part.ATTACHMENT. It is visible now.
But now on to the problem...Sometimes, an e-mail (.eml file) is added to an other e-mail as an attachment. But, this e-mail isn't included as disposition attachment, but just as an other message within the message. It doesn't even have a file name. It seems like this is just a forward or something.
This e-mail should be visible as an attachment of the surrounding e-mail within the web interface. Does anyone have an idea how i can accomplish this and extract this body part as an attachment? Are there any headers i can check? (I printed the headers of the body part and there were only three, content-type, encoding en such ... but nothing like disposition. I tried to set the disposition to attachment to make it visible as an attachment, but that didn't work.
Thanks already in advance.