I have a java program which checks a particular mailbox periodically for new messages sent by users and once there is a new message, it processes that message and copies that message to a particular record. Also if there are any attachments associated with that email, it will take those attachments and attach them to the particular record. All this is working fine. But when a user who is sending an email has an image as part of his email signature, that image is coming as an attachment to my mailbox and my code is picking up that attachment and appending it to the record as a new attachment. Is there a way to differentiate between the normal attachments that a user sends and the email signature image so that I can check for those image attachments before attaching to my record. Any help is greatly appreciated.
There's no standard for these sorts of "email signatures" so there's no guaranteed way to detect them.
A common way to format such a message would be to put the message text as a text/html part
inside a maultipart/related part, with an image/jpeg part containing the image.
Normally attachments should be part of a multipart/mixed part, and should have a Content-Disposition
But many mailers play fast and loose with these rules, so you may have to experiment with some
heuristics to detect such signatures reliably.