You wrote:
i want to find that whether text in MIME mail is attachment or mail content.
As you've discovered, there's effectively no difference. A text attachment will usually have a filename suggested in the content-disposition, but not always. The "content" or mail body will typically be the first entity - but again, not always.
If you describe what you're trying to do more specifically, maybe we can suggest another way to do it. | [reply] |
Hi McD
Actually i want to compress mail attachments(not the mail contents).
if the attachments are in BASE64 encoding, its easy to find out the attachments and compress it. but if the attachments are text file so its encoding is 7bit.
so i want to detach the text file and compress it.
Thanks.
| [reply] |
Okay, I think I get it. You want to compress "attachments", but not the "mail body" and text attachments are throwing you because they look like the mail body.
That's going to be tricky - don't forget that MIME entities can nest, you often have to process them recursively. (Think of a MIME message which has an attached MIME message, like a mail forward...)
There are also semantic considerations - such as what the effects might be of compressing parts of an entity of type multipart/related, you might break the composite entity.
But speaking in terms of a quick-and-dirty solution that works 90% of the time, I'd say go ahead and key off the presence of a suggested file name. Process the message entity by entity, and if there's a filename suggestion (in content-type or content-disposition, as you saw) then assume it's an attachment and replace it with a compressed version of itself.
You can throw in some heuristics to make it little more robust, like never compressing the first text entity you come across, never compressing a single-part message (only one entity), and not descending inside of multipart/alternative entities (which often contain the text/html and text/plain versions of the "message body").
Good luck!
| [reply] |
when i try to read the content-type, disposition, etc fields of an text attachment, it looks same as the content of mail.
Show your code (and complete message, like multi-simple.msg), otherwise see
examples/mimedump it shows how.
| [reply] |
Why didn't you use code tags? | [reply] |