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