Package org.apache.commons.mail.util
Class MimeMessageParser
java.lang.Object
org.apache.commons.mail.util.MimeMessageParser
Parses a MimeMessage and stores the individual parts such a plain text, HTML text and attachments.
- Since:
- 1.3
-
Constructor Summary
ConstructorsConstructorDescriptionMimeMessageParser(MimeMessage mimeMessage) Constructs an instance with the MimeMessage to be extracted. -
Method Summary
Modifier and TypeMethodDescriptionjavax.activation.DataSourceFind an attachment using its content-id.javax.activation.DataSourcefindAttachmentByName(String name) Find an attachment using its name.List<javax.activation.DataSource> Gets the attachment list.getBcc()Gets the BCC Address list.getCc()Gets the CC Address list.Returns a collection of all content-ids in the parsed message.getFrom()Gets the FROM field.Gets the htmlContent if any.Gets the MimeMessage.Gets the plain content if any.Gets the 'replyTo' address of the email.Gets the MIME message subject.getTo()Gets the MIME message 'to' list.booleanTests if attachments are present.booleanTests is HTML content is present.booleanTests is plain content is present.booleanTests whether this is multipart.parse()Does the actual extraction.
-
Constructor Details
-
MimeMessageParser
Constructs an instance with the MimeMessage to be extracted.- Parameters:
mimeMessage- the message to parse
-
-
Method Details
-
findAttachmentByCid
Find an attachment using its content-id.The content-id must be stripped of any angle brackets, i.e. "part1" instead of "<part1>".
- Parameters:
cid- the content-id of the attachment- Returns:
- the corresponding datasource or null if nothing was found
- Since:
- 1.3.4
-
findAttachmentByName
Find an attachment using its name.- Parameters:
name- the name of the attachment- Returns:
- the corresponding datasource or null if nothing was found
-
getAttachmentList
Gets the attachment list.- Returns:
- Returns the attachment list.
-
getBcc
Gets the BCC Address list.- Returns:
- the 'BCC' recipients of the message
- Throws:
MessagingException- determining the recipients failed
-
getCc
Gets the CC Address list.- Returns:
- the 'CC' recipients of the message
- Throws:
MessagingException- determining the recipients failed
-
getContentIds
Returns a collection of all content-ids in the parsed message.The content-ids are stripped of any angle brackets, i.e. "part1" instead of "<part1>".
- Returns:
- the collection of content ids.
- Since:
- 1.3.4
-
getFrom
Gets the FROM field.- Returns:
- the FROM field of the message
- Throws:
MessagingException- parsing the mime message failed
-
getHtmlContent
Gets the htmlContent if any.- Returns:
- Returns the htmlContent if any
-
getMimeMessage
Gets the MimeMessage.- Returns:
- Returns the mimeMessage.
-
getPlainContent
Gets the plain content if any.- Returns:
- Returns the plainContent if any
-
getReplyTo
Gets the 'replyTo' address of the email.- Returns:
- the 'replyTo' address of the email
- Throws:
MessagingException- parsing the mime message failed
-
getSubject
Gets the MIME message subject.- Returns:
- the MIME message subject.
- Throws:
MessagingException- parsing the mime message failed.
-
getTo
Gets the MIME message 'to' list.- Returns:
- the 'to' recipients of the message.
- Throws:
MessagingException- determining the recipients failed
-
hasAttachments
public boolean hasAttachments()Tests if attachments are present.- Returns:
- true if attachments are present.
-
hasHtmlContent
public boolean hasHtmlContent()Tests is HTML content is present.- Returns:
- true if HTML content is present.
-
hasPlainContent
public boolean hasPlainContent()Tests is plain content is present.- Returns:
- true if a plain content is present.
-
isMultipart
public boolean isMultipart()Tests whether this is multipart.- Returns:
- Returns the isMultiPart.
-
parse
Does the actual extraction.- Returns:
- this instance
- Throws:
MessagingException- parsing the mime message failedIOException- parsing the mime message failed
-