Package com.axelor.mail
Class MailParser
java.lang.Object
com.axelor.mail.MailParser
Parses a
MimeMessage and stores the individual parts such as context text, attachments
etc.-
Constructor Summary
ConstructorsConstructorDescriptionMailParser(jakarta.mail.internet.MimeMessage message) Create a newMailParserfor the givenMimeMessage. -
Method Summary
Modifier and TypeMethodDescriptionList<jakarta.activation.DataSource> Get attachments.List<jakarta.mail.internet.InternetAddress> getBcc()Get list of "bcc" recipients of the message.List<jakarta.mail.internet.InternetAddress> getCc()Get list of "cc" recipients of the message.jakarta.mail.internet.InternetAddressgetFrom()Get "from" address of the message.Get the first header value for the the header name.getHtml()Get the html content if available.jakarta.mail.internet.InternetAddressGet "replyTo" address of the message.Get sanitized safe html.Get the message subject line.Get the first line of the email as summary.getText()Get plain text content if available.List<jakarta.mail.internet.InternetAddress> getTo()Get list of "to" recipients of the message.booleanWhether the message has attachments.booleanWhether the message is multipart message.parse()Parse the message.
-
Constructor Details
-
MailParser
public MailParser(jakarta.mail.internet.MimeMessage message) Create a newMailParserfor the givenMimeMessage.- Parameters:
message- theMimeMessageto parse
-
-
Method Details
-
parse
Parse the message.- Returns:
- the
MailParserinstance itself - Throws:
IOException- generally thrown byDataHandlerjakarta.mail.MessagingException- for failures
-
getTo
Get list of "to" recipients of the message.- Returns:
- list of
InternetAddress - Throws:
jakarta.mail.MessagingException- if unable to get addresses
-
getCc
Get list of "cc" recipients of the message.- Returns:
- list of
InternetAddress - Throws:
jakarta.mail.MessagingException- if unable to get addresses
-
getBcc
Get list of "bcc" recipients of the message.- Returns:
- list of
InternetAddress - Throws:
jakarta.mail.MessagingException- if unable to get addresses
-
getFrom
public jakarta.mail.internet.InternetAddress getFrom() throws jakarta.mail.MessagingExceptionGet "from" address of the message.- Returns:
InternetAddressor null if unable to read "from" field- Throws:
jakarta.mail.MessagingException- if unable to get address
-
getReplyTo
public jakarta.mail.internet.InternetAddress getReplyTo() throws jakarta.mail.MessagingExceptionGet "replyTo" address of the message.- Returns:
InternetAddressor null unable to read "replyTo" field.- Throws:
jakarta.mail.MessagingException- if unable to get address
-
getSubject
Get the message subject line.- Returns:
- message subject line
- Throws:
jakarta.mail.MessagingException- for failure
-
getText
Get plain text content if available.- Returns:
- the content as plain text
-
getHtml
Get the html content if available.- Returns:
- the html content
-
getSummary
Get the first line of the email as summary.- Returns:
- return short text as summary
-
getSafeHtml
Get sanitized safe html.- Returns:
- sanitized html
-
isMultiPart
public boolean isMultiPart()Whether the message is multipart message.- Returns:
- true if multipart false otherwise
-
hasAttachments
public boolean hasAttachments()Whether the message has attachments.- Returns:
- true if has attachments false otherwise
-
getAttachments
Get attachments.- Returns:
- list of
DataSource
-
getHeader
Get the first header value for the the header name.- Parameters:
name- header name- Returns:
- first header value if found else null
- Throws:
jakarta.mail.MessagingException- for failures
-