Class MailUtil
java.lang.Object
com.logicaldoc.core.communication.MailUtil
Utility methods for handling emails
- Since:
- 7.6.4
- Author:
- Marco Meschieri - LogicalDOC
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic intcountEmlAttachments(File emlFile) static intstatic intcountMsgAttachments(File msgFile) static intstatic booleanemlContainsAttachments(File emlFile) static booleanstatic StringextractMessageText(jakarta.mail.Message message) Extracts just the body of texts parts in the given email messagestatic StringgetAddressEmail(jakarta.mail.Address a) Extracts the address emailstatic StringgetAddressName(jakarta.mail.Address a) Extracts the address namestatic EMailmessageToMail(jakarta.mail.Message msg, boolean extractAttachmentContent) Builds an EMail from a Message.static EMailmessageToMail(File emlFile, boolean extractAttachmentContent) Builds an EMail from a .eml file.static EMailmessageToMail(InputStream is, boolean extractAttachmentContent) Builds an EMail from a streamstatic booleanmsgContainsAttachments(File msgFile) static booleanstatic EMailBuilds an EMail from a .msg file.static EMailmsgToMail(InputStream is, boolean extractAttachmentContent) Builds an EMail from a .msg filestatic jakarta.mail.internet.MimeMessagereadMime(InputStream is) Constructs a MimeMessage from a stream
- 
Field Details- 
NO_SUBJECT- See Also:
 
- 
NO_BODY- See Also:
 
 
- 
- 
Constructor Details- 
MailUtilpublic MailUtil()
 
- 
- 
Method Details- 
emlContainsAttachments
- 
countEmlAttachments
- 
msgToMailpublic static EMail msgToMail(InputStream is, boolean extractAttachmentContent) throws IOException, jakarta.mail.MessagingException, org.bouncycastle.cms.CMSException Builds an EMail from a .msg file- Parameters:
- is- the input stream
- extractAttachmentContent- if the attachments have to be extracted
- Returns:
- the EMail object
- Throws:
- IOException- I/O error
- jakarta.mail.MessagingException- error reading the contents
- org.bouncycastle.cms.CMSException- error reading the contents
 
- 
msgToMailpublic static EMail msgToMail(File msgFile, boolean extractAttachmentContent) throws IOException, jakarta.mail.MessagingException, org.bouncycastle.cms.CMSException Builds an EMail from a .msg file.- Parameters:
- msgFile- the input file
- extractAttachmentContent- if you want to extract the attachment files
- Returns:
- the EMail object
- Throws:
- IOException- I/O error
- org.bouncycastle.cms.CMSException- cannot read the content
- jakarta.mail.MessagingException- cannot read the content
 
- 
messageToMailpublic static EMail messageToMail(InputStream is, boolean extractAttachmentContent) throws jakarta.mail.MessagingException, IOException Builds an EMail from a stream- Parameters:
- is- the stream to read
- extractAttachmentContent- if you want to extract the attachment files
- Returns:
- the EMail object
- Throws:
- jakarta.mail.MessagingException- raised if the message cannot be read
- IOException- raised if case of I/O errors
 
- 
readMimepublic static jakarta.mail.internet.MimeMessage readMime(InputStream is) throws jakarta.mail.MessagingException Constructs a MimeMessage from a stream- Parameters:
- is- the input stream
- Returns:
- the creaed message
- Throws:
- jakarta.mail.MessagingException- the contents are invalid
 
- 
messageToMailpublic static EMail messageToMail(File emlFile, boolean extractAttachmentContent) throws jakarta.mail.MessagingException, IOException Builds an EMail from a .eml file.- Parameters:
- emlFile- the input file
- extractAttachmentContent- if you want to extract the attachment files
- Returns:
- the EMail object
- Throws:
- jakarta.mail.MessagingException- if the source file cannot be read
- IOException- raised if case of I/O errors
 
- 
messageToMailpublic static EMail messageToMail(jakarta.mail.Message msg, boolean extractAttachmentContent) throws jakarta.mail.MessagingException, IOException Builds an EMail from a Message.- Parameters:
- msg- the source message
- extractAttachmentContent- if the binary of the attachments has to be extracted
- Returns:
- The EMail instance
- Throws:
- jakarta.mail.MessagingException- error reading the message
- IOException- error in I/O operations
 
- 
getAddressNameExtracts the address name- Parameters:
- a- the address
- Returns:
- the name
 
- 
getAddressEmailExtracts the address email- Parameters:
- a- the address
- Returns:
- the email
 
- 
countMsgAttachments
- 
msgContainsAttachments
- 
countMsgAttachments
- 
msgContainsAttachments
- 
countEmlAttachments
- 
emlContainsAttachments
- 
extractMessageTextpublic static String extractMessageText(jakarta.mail.Message message) throws jakarta.mail.MessagingException, IOException Extracts just the body of texts parts in the given email message- Parameters:
- message- the email message
- Returns:
- the message text
- Throws:
- jakarta.mail.MessagingException- Error in traversing the part
- IOException- generic I/O error
 
 
-