Analysis of email attachments via mime4j

I use the small java smtp library ( http://code.google.com/p/subethasmtp/ ), so I have to parse incoming emails in separate components, namely the body, attachments, etc.

I am trying to use mime4j, but the documentation tells me that mime4j can give an event notification or a token notification and nothing more. To remove body and attachments, etc. I had to use my own logic inside event handlers. Is my observation correct?

If so, how can I use mime4j to use for my requirement. Please suggest.

I really need an approach that takes an smtp data stream and returns me with an array of anchor links or threads in a fully parsed form in java. Please, help.

Thanks in advance

Ashish Sharma

+5
source share
2 answers

Mime4j can definitely do what you need. Subclass org.apache.james.mime4j.message.SimpleContentHandler and implement the bodyDecoded method. Then pass this subclass to the MimeStreamParser instance. You will see that bodyDecoded is called once per body or attachment, and the stream it gives you contains data with Base64 or Quoted-Printable decoding already done.

API , DOM- , org.apache.james.mime4j.message.Message. Message.getBody(), , , , Multipart, TextBody, BinaryBody .. Multipart, Multipart.getBodyParts .

+9

@ , SubEthaSmtp, , SubEtha: http://code.google.com/p/subetha/source/browse/trunk/src/org/subethamail/common/SubEthaMessage.java

SMTPMessage getPart(). javax.mail.Part , , .

+2

All Articles