Class MailUtil
java.lang.Object
com.logicaldoc.core.communication.MailUtil
Utility methods for handling emails
- Since:
- 7.6.4
- Author:
- Marco Meschieri - LogicalDOC
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
countEmlAttachments
(File emlFile) static int
static int
countMsgAttachments
(File msgFile) static int
static boolean
emlContainsAttachments
(File emlFile) static boolean
static String
extractMessageText
(javax.mail.Message message) Extracts just the body of texts parts in the given email messagestatic String
getAddressEmail
(javax.mail.Address a) Extracts the address emailstatic String
getAddressName
(javax.mail.Address a) Extracts the address namestatic EMail
messageToMail
(File emlFile, boolean extractAttachmentContent) Builds an EMail from a .eml file.static EMail
messageToMail
(InputStream is, boolean extractAttachmentContent) Builds an EMail from a streamstatic EMail
messageToMail
(javax.mail.Message msg, boolean extractAttachmentContent) Builds an EMail from a Message.static boolean
msgContainsAttachments
(File msgFile) static boolean
static EMail
Builds an EMail from a .msg file.static EMail
msgToMail
(InputStream is, boolean extractAttachmentContent) Builds an EMail from a .msg filestatic javax.mail.internet.MimeMessage
readMime
(InputStream is) Constructs a MimeMessage from a stream
-
Field Details
-
NO_SUBJECT
- See Also:
-
NO_BODY
- See Also:
-
-
Constructor Details
-
MailUtil
public MailUtil()
-
-
Method Details
-
emlContainsAttachments
-
countEmlAttachments
-
msgToMail
public static EMail msgToMail(InputStream is, boolean extractAttachmentContent) throws IOException, javax.mail.MessagingException, org.bouncycastle.cms.CMSException Builds an EMail from a .msg file- Parameters:
is
- the input streamextractAttachmentContent
- if the attachments have to be extracted- Returns:
- the EMail object
- Throws:
IOException
- I/O errorjavax.mail.MessagingException
- error reading the contentsorg.bouncycastle.cms.CMSException
- error reading the contents
-
msgToMail
public static EMail msgToMail(File msgFile, boolean extractAttachmentContent) throws IOException, javax.mail.MessagingException, org.bouncycastle.cms.CMSException Builds an EMail from a .msg file.- Parameters:
msgFile
- the input fileextractAttachmentContent
- if you want to extract the attachment files- Returns:
- the EMail object
- Throws:
IOException
- I/O errororg.bouncycastle.cms.CMSException
- cannot read the contentjavax.mail.MessagingException
- cannot read the content
-
messageToMail
public static EMail messageToMail(InputStream is, boolean extractAttachmentContent) throws javax.mail.MessagingException, IOException Builds an EMail from a stream- Parameters:
is
- the stream to readextractAttachmentContent
- if you want to extract the attachment files- Returns:
- the EMail object
- Throws:
javax.mail.MessagingException
- raised if the message cannot be readIOException
- raised if case of I/O errors
-
readMime
public static javax.mail.internet.MimeMessage readMime(InputStream is) throws javax.mail.MessagingException Constructs a MimeMessage from a stream- Parameters:
is
- the input stream- Returns:
- the creaed message
- Throws:
javax.mail.MessagingException
- the contents are invalid
-
messageToMail
public static EMail messageToMail(File emlFile, boolean extractAttachmentContent) throws javax.mail.MessagingException, IOException Builds an EMail from a .eml file.- Parameters:
emlFile
- the input fileextractAttachmentContent
- if you want to extract the attachment files- Returns:
- the EMail object
- Throws:
javax.mail.MessagingException
- if the source file cannot be readIOException
- raised if case of I/O errors
-
messageToMail
public static EMail messageToMail(javax.mail.Message msg, boolean extractAttachmentContent) throws javax.mail.MessagingException, IOException Builds an EMail from a Message.- Parameters:
msg
- the source messageextractAttachmentContent
- if the binary of the attachments has to be extracted- Returns:
- The EMail instance
- Throws:
javax.mail.MessagingException
- error reading the messageIOException
- error in I/O operations
-
getAddressName
Extracts the address name- Parameters:
a
- the address- Returns:
- the name
-
getAddressEmail
Extracts the address email- Parameters:
a
- the address- Returns:
- the email
-
countMsgAttachments
-
msgContainsAttachments
-
countMsgAttachments
-
msgContainsAttachments
-
countEmlAttachments
-
emlContainsAttachments
-
extractMessageText
public static String extractMessageText(javax.mail.Message message) throws javax.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:
javax.mail.MessagingException
- Error in traversing the partIOException
- generic I/O error
-