public class MimeMessageParser extends java.lang.Object
| Constructor | Description |
|---|---|
MimeMessageParser(javax.mail.internet.MimeMessage message) |
Constructs an instance with the MimeMessage to be extracted.
|
| Modifier and Type | Method | Description |
|---|---|---|
protected javax.activation.DataSource |
createDataSource(javax.mail.Multipart parent,
javax.mail.internet.MimePart part) |
Parses the MimePart to create a DataSource.
|
javax.activation.DataSource |
findAttachmentByCid(java.lang.String cid) |
Find an attachment using its content-id.
|
javax.activation.DataSource |
findAttachmentByName(java.lang.String name) |
Find an attachment using its name.
|
java.util.List<javax.activation.DataSource> |
getAttachmentList() |
|
java.util.List<javax.mail.Address> |
getBcc() |
|
java.util.List<javax.mail.Address> |
getCc() |
|
java.util.Collection<java.lang.String> |
getContentIds() |
Returns a collection of all content-ids in the parsed message.
|
protected java.lang.String |
getDataSourceName(javax.mail.Part part,
javax.activation.DataSource dataSource) |
Determines the name of the data source if it is not already set.
|
java.lang.String |
getFrom() |
|
java.lang.String |
getHtmlContent() |
|
javax.mail.internet.MimeMessage |
getMimeMessage() |
|
java.lang.String |
getPlainContent() |
|
java.lang.String |
getReplyTo() |
|
java.lang.String |
getSubject() |
|
java.util.List<javax.mail.Address> |
getTo() |
|
boolean |
hasAttachments() |
|
boolean |
hasHtmlContent() |
|
boolean |
hasPlainContent() |
|
boolean |
isMultipart() |
|
MimeMessageParser |
parse() |
Does the actual extraction.
|
protected void |
parse(javax.mail.Multipart parent,
javax.mail.internet.MimePart part) |
Extracts the content of a MimeMessage recursively.
|
public MimeMessageParser(javax.mail.internet.MimeMessage message)
message - the message to parsepublic MimeMessageParser parse() throws java.lang.Exception
java.lang.Exception - parsing the mime message failedpublic java.util.List<javax.mail.Address> getTo() throws java.lang.Exception
java.lang.Exception - determining the recipients failedpublic java.util.List<javax.mail.Address> getCc() throws java.lang.Exception
java.lang.Exception - determining the recipients failedpublic java.util.List<javax.mail.Address> getBcc() throws java.lang.Exception
java.lang.Exception - determining the recipients failedpublic java.lang.String getFrom() throws java.lang.Exception
java.lang.Exception - parsing the mime message failedpublic java.lang.String getReplyTo() throws java.lang.Exception
java.lang.Exception - parsing the mime message failedpublic java.lang.String getSubject() throws java.lang.Exception
java.lang.Exception - parsing the mime message failedprotected void parse(javax.mail.Multipart parent, javax.mail.internet.MimePart part) throws javax.mail.MessagingException, java.io.IOException
parent - the parent multi-partpart - the current MimePartjavax.mail.MessagingException - parsing the MimeMessage failedjava.io.IOException - parsing the MimeMessage failedprotected javax.activation.DataSource createDataSource(javax.mail.Multipart parent, javax.mail.internet.MimePart part) throws javax.mail.MessagingException, java.io.IOException
parent - the parent multi-partpart - the current part to be processedjavax.mail.MessagingException - creating the DataSource failedjava.io.IOException - creating the DataSource failedpublic javax.mail.internet.MimeMessage getMimeMessage()
public boolean isMultipart()
public java.lang.String getPlainContent()
public java.util.List<javax.activation.DataSource> getAttachmentList()
public java.util.Collection<java.lang.String> getContentIds()
The content-ids are stripped of any angle brackets, i.e. "part1" instead of "<part1>".
public java.lang.String getHtmlContent()
public boolean hasPlainContent()
public boolean hasHtmlContent()
public boolean hasAttachments()
public javax.activation.DataSource findAttachmentByName(java.lang.String name)
name - the name of the attachmentpublic javax.activation.DataSource findAttachmentByCid(java.lang.String cid)
The content-id must be stripped of any angle brackets, i.e. "part1" instead of "<part1>".
cid - the content-id of the attachmentprotected java.lang.String getDataSourceName(javax.mail.Part part, javax.activation.DataSource dataSource) throws javax.mail.MessagingException, java.io.UnsupportedEncodingException
part - the mail partdataSource - the data sourcenull if no name can be determinedjavax.mail.MessagingException - accessing the part failedjava.io.UnsupportedEncodingException - decoding the text failed