public class MailUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
MAIL_TYPE_MSG_RFC822 |
static String |
MAIL_TYPE_TEXT_HTML |
static String |
MAIL_TYPE_TEXT_PAIN |
| Constructor and Description |
|---|
MailUtil() |
| Modifier and Type | Method and Description |
|---|---|
static String |
decodeText(String encodedText)
decode test
|
static String |
getFrom(javax.mail.Message msg)
get mail from
|
static String |
getPriority(javax.mail.Message msg)
priority
|
static String |
getReceiveAddress(javax.mail.Message msg,
javax.mail.Message.RecipientType type)
RecipientType.
|
static String |
getSender(javax.mail.internet.MimeMessage msg)
get sender
|
static String |
getSentDate(javax.mail.Message msg,
String pattern)
get send date
|
static String |
getSubject(javax.mail.Message msg)
get the topic of mail
|
static boolean |
hasAttachment(javax.mail.Part part)
mail has attachment or not
|
static boolean |
isReplySign(javax.mail.Message msg)
is mail need reply
|
static boolean |
isSeen(javax.mail.Message msg)
mail is seen or not
|
static void |
parseAttachment(javax.mail.Message msg,
javax.mail.Part part,
MailAttachmentHandler athmHandler) |
static void |
parseMailTextContent(javax.mail.Part part,
Map<String,StringBuffer> content)
get mail content by text
|
static void |
parseMessage(MailBodyHandler bodyHandler,
MailAttachmentHandler athmHandler,
javax.mail.Message... messages)
parse mail
|
static void |
receiveMail(Properties emailProps,
String email,
String password,
boolean isReadOnly,
MailFolderHandler folderHandler,
MailBodyHandler bodyHandler,
MailAttachmentHandler athmHandler) |
static void |
sendHtmlMail(Properties emailProps,
String email,
String password,
String[] toArr,
String[] ccArr,
String[] bccArr,
String subject,
String html,
Map<String,DataSource> related,
Map<String,DataSource> attachments)
send email
|
static void |
sendTextMail(Properties emailProps,
String email,
String password,
String[] toArr,
String[] ccArr,
String[] bccArr,
String subject,
String text)
send email
|
static void |
sendTextMail(Properties emailProps,
String email,
String password,
String[] toArr,
String[] ccArr,
String[] bccArr,
String subject,
String text,
Map<String,DataSource> attachments)
send email
|
public static final String MAIL_TYPE_TEXT_PAIN
public static final String MAIL_TYPE_TEXT_HTML
public static final String MAIL_TYPE_MSG_RFC822
public static void sendTextMail(Properties emailProps, String email, String password, String[] toArr, String[] ccArr, String[] bccArr, String subject, String text) throws Exception
emailProps - email propsemail - emailpassword - passwordtoArr - toArrccArr - ccArrbccArr - bccArrsubject - subjecttext - textException - exceptionpublic static void sendTextMail(Properties emailProps, String email, String password, String[] toArr, String[] ccArr, String[] bccArr, String subject, String text, Map<String,DataSource> attachments) throws Exception
emailProps - email propsemail - emailpassword - passwordtoArr - toArrccArr - ccArrbccArr - bccArrsubject - subjecttext - textattachments - attachmentsException - exceptionpublic static void sendHtmlMail(Properties emailProps, String email, String password, String[] toArr, String[] ccArr, String[] bccArr, String subject, String html, Map<String,DataSource> related, Map<String,DataSource> attachments) throws Exception
emailProps - email propsemail - emailpassword - passwordtoArr - toArrccArr - ccArrbccArr - bccArrsubject - subjecthtml - htmlrelated - related attachmentsattachments - attachmentsException - exceptionpublic static void receiveMail(Properties emailProps, String email, String password, boolean isReadOnly, MailFolderHandler folderHandler, MailBodyHandler bodyHandler, MailAttachmentHandler athmHandler) throws Exception
emailProps - mail server connection propsemail - email addresspassword - email passwardisReadOnly - is read onlyfolderHandler - handle every mail folder in mail accountbodyHandler - handle mail body in every mail folderathmHandler - handle mail attachment in every mailException - something errpublic static void parseMessage(MailBodyHandler bodyHandler, MailAttachmentHandler athmHandler, javax.mail.Message... messages) throws javax.mail.MessagingException, IOException
bodyHandler - handle mail bodyathmHandler - handle mail attachementmessages - message ( could be one or many) to parsejavax.mail.MessagingException - something errIOException - something errpublic static String getSubject(javax.mail.Message msg) throws UnsupportedEncodingException, javax.mail.MessagingException
msg - mail bodyUnsupportedEncodingException - io errjavax.mail.MessagingException - io errpublic static String getSender(javax.mail.internet.MimeMessage msg) throws javax.mail.MessagingException, UnsupportedEncodingException
msg - mailjavax.mail.MessagingException - something errUnsupportedEncodingException - something errpublic static String getFrom(javax.mail.Message msg) throws javax.mail.MessagingException, UnsupportedEncodingException
msg - mailjavax.mail.MessagingException - something errUnsupportedEncodingException - something errpublic static String getReceiveAddress(javax.mail.Message msg, javax.mail.Message.RecipientType type) throws javax.mail.MessagingException
msg - mailtype - recipient type / Message.RecipientType.TO /
Message.RecipientType.CC / Message.RecipientType.BCC. Return all
by default.javax.mail.MessagingException - something errpublic static String getSentDate(javax.mail.Message msg, String pattern) throws javax.mail.MessagingException
msg - mailpattern - String for java date formatjavax.mail.MessagingException - something errpublic static boolean hasAttachment(javax.mail.Part part)
throws javax.mail.MessagingException,
IOException
part - mailjavax.mail.MessagingException - something errIOException - something errpublic static boolean isSeen(javax.mail.Message msg)
throws javax.mail.MessagingException
msg - mailjavax.mail.MessagingException - something errpublic static boolean isReplySign(javax.mail.Message msg)
throws javax.mail.MessagingException
msg - mailjavax.mail.MessagingException - something errpublic static String getPriority(javax.mail.Message msg) throws javax.mail.MessagingException
msg - mailjavax.mail.MessagingException - something errpublic static void parseMailTextContent(javax.mail.Part part,
Map<String,StringBuffer> content)
throws javax.mail.MessagingException,
IOException
part - mail body partcontent - content of mail bodyjavax.mail.MessagingException - something errIOException - something errpublic static void parseAttachment(javax.mail.Message msg,
javax.mail.Part part,
MailAttachmentHandler athmHandler)
throws UnsupportedEncodingException,
javax.mail.MessagingException,
FileNotFoundException,
IOException
msg - mailpart - part of emailathmHandler - attachment handlerUnsupportedEncodingException - something errjavax.mail.MessagingException - something errFileNotFoundException - something errIOException - something errpublic static String decodeText(String encodedText) throws UnsupportedEncodingException
encodedText - MimeUtility.encodeText(String text)UnsupportedEncodingException - something errCopyright © 2019. All rights reserved.