Class MessageUtil


  • public class MessageUtil
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      protected static void addHeaders​(MailMessage mailMessage, javax.mail.Message message)  
      static javax.mail.Message buildMessage​(MailMessage mailMessage)
      Build a MimeMessage bodyPartEncoding values are: text/plain; charset=UTF-8 | text/html; charset=UTF-8
      static MailMessage[] buildOneMessageForEach​(MailMessage mailMessage)
      Create one message one for each recipients.
      static java.util.Collection<MailMessage.Part> decodeMultipart​(javax.mail.Message msg)  
      protected static void fillMessageContent​(MailMessage mailMessage, javax.mail.Message message)  
      static java.lang.String getMessageIdQuietly​(javax.mail.Message msg)
      Returns the messageId for the given message.
      static java.util.TreeSet<java.lang.String> getToRecipientSet​(java.util.Collection<MailMessage> messages)
      Utility method which create a TreeSet of all to recipients email from the specified messages.
      static void logMessages​(MailMessage msg)
      This method is used to log them using log4j (for example when mail is disabled).
      static void logMessages​(MailMessage[] msgs)
      This method is used to log them using log4j (for example when mail is disabled).
      static java.io.File writeEml​(javax.mail.Message msg)
      Write a Message to a file
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • logMessages

        public static void logMessages​(MailMessage msg)
        This method is used to log them using log4j (for example when mail is disabled).
        Parameters:
        msg - the message that should have been sent.
      • logMessages

        public static void logMessages​(MailMessage[] msgs)
        This method is used to log them using log4j (for example when mail is disabled).
        Parameters:
        msgs - the message array that will be logged.
      • buildMessage

        public static javax.mail.Message buildMessage​(MailMessage mailMessage)
                                               throws javax.mail.MessagingException
        Build a MimeMessage bodyPartEncoding values are: text/plain; charset=UTF-8 | text/html; charset=UTF-8
        Parameters:
        mailMessage - the MailMessage
        Returns:
        a new Message instance
        Throws:
        javax.mail.MessagingException - When including attachments with your messages, if your program is a servlet, your users must upload the attachment besides tell you where to send the message. Uploading each file can be handled with a form encoding type of multipart/form-data.
      • buildOneMessageForEach

        public static MailMessage[] buildOneMessageForEach​(MailMessage mailMessage)
                                                    throws javax.mail.MessagingException
        Create one message one for each recipients.
        Parameters:
        mailMessage - the MailMessage
        Returns:
        the message
        Throws:
        javax.mail.MessagingException - if an error occurs
      • addHeaders

        protected static void addHeaders​(MailMessage mailMessage,
                                         javax.mail.Message message)
                                  throws javax.mail.MessagingException
        Throws:
        javax.mail.MessagingException
      • fillMessageContent

        protected static void fillMessageContent​(MailMessage mailMessage,
                                                 javax.mail.Message message)
                                          throws javax.mail.MessagingException
        Throws:
        javax.mail.MessagingException
      • getToRecipientSet

        public static java.util.TreeSet<java.lang.String> getToRecipientSet​(java.util.Collection<MailMessage> messages)
        Utility method which create a TreeSet of all to recipients email from the specified messages.
        Parameters:
        messages - the message in which to retrieve recipients
        Returns:
        a Set of email, never return null.
        Since:
        jcms-10.0.5
      • getMessageIdQuietly

        public static java.lang.String getMessageIdQuietly​(javax.mail.Message msg)
        Returns the messageId for the given message. Trying to catch and log messaging exception.
        Parameters:
        msg - the javax.mail.Message
        Returns:
        String the message Id or null
      • writeEml

        public static java.io.File writeEml​(javax.mail.Message msg)
        Write a Message to a file
        Parameters:
        msg - the Message
        Returns:
        the File with the message saved in
      • decodeMultipart

        public static java.util.Collection<MailMessage.Part> decodeMultipart​(javax.mail.Message msg)
                                                                      throws javax.mail.MessagingException,
                                                                             java.io.IOException
        Throws:
        javax.mail.MessagingException
        java.io.IOException