Class MailUtil
- java.lang.Object
-
- com.logicaldoc.core.communication.MailUtil
-
public class MailUtil extends Object
Utility methods for handling emails- Since:
- 7.6.4
- Author:
- Marco Meschieri - LogicalDOC
-
-
Field Summary
Fields Modifier and Type Field Description static StringNO_BODYstatic StringNO_SUBJECT
-
Constructor Summary
Constructors Constructor Description MailUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanemlContainsAttachments(File emlFile)static booleanemlContainsAttachments(InputStream is)static StringgetAddressEmail(javax.mail.Address a)Extracts the address emailstatic StringgetAddressName(javax.mail.Address a)Extracts the address namestatic EMailmessageToMail(File emlFile, boolean extractAttachmentContent)Builds an EMail from a .eml file.static EMailmessageToMail(InputStream is, boolean extractAttachmentContent)Builds an EMail from a streamstatic EMailmessageToMail(javax.mail.Message msg, boolean extractAttachmentContent)Builds an EMail from a Message.static booleanmsgContainsAttachments(File msgFile)static booleanmsgContainsAttachments(InputStream is)static EMailmsgToMail(File msgFile, boolean extractAttachmentContent)Builds an EMail from a .msg file.static EMailmsgToMail(InputStream is, boolean extractAttachmentContent)Builds an EMail from a .msg file
-
-
-
Field Detail
-
NO_SUBJECT
public static final String NO_SUBJECT
- See Also:
- Constant Field Values
-
NO_BODY
public static final String NO_BODY
- See Also:
- Constant Field Values
-
-
Method Detail
-
emlContainsAttachments
public static boolean emlContainsAttachments(InputStream is)
-
msgToMail
public static EMail msgToMail(InputStream is, boolean extractAttachmentContent) throws Exception
Builds an EMail from a .msg file- Parameters:
is- the input streamextractAttachmentContent- if the attachments have to be extracted- Returns:
- the EMail object
- Throws:
Exception- error reading the contents
-
msgToMail
public static EMail msgToMail(File msgFile, boolean extractAttachmentContent) throws Exception
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:
Exception- raised if the message cannot be read
-
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
-
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
public static String getAddressName(javax.mail.Address a)
Extracts the address name- Parameters:
a- the address- Returns:
- the name
-
getAddressEmail
public static String getAddressEmail(javax.mail.Address a)
Extracts the address email- Parameters:
a- the address- Returns:
- the email
-
msgContainsAttachments
public static boolean msgContainsAttachments(File msgFile)
-
msgContainsAttachments
public static boolean msgContainsAttachments(InputStream is)
-
emlContainsAttachments
public static boolean emlContainsAttachments(File emlFile)
-
-