Class MimeMessageUtils


  • public final class MimeMessageUtils
    extends java.lang.Object
    Static helper methods.
    Since:
    1.3
    • Method Detail

      • createMimeMessage

        public static MimeMessage createMimeMessage​(Session session,
                                                    byte[] source)
                                             throws MessagingException,
                                                    java.io.IOException
        Create a MimeMessage.
        Parameters:
        session - the mail session
        source - the input data
        Returns:
        the MimeMessage
        Throws:
        MessagingException - creating the MimeMessage failed
        java.io.IOException - creating the MimeMessage failed
      • createMimeMessage

        public static MimeMessage createMimeMessage​(Session session,
                                                    java.io.File source)
                                             throws MessagingException,
                                                    java.io.IOException
        Create a MimeMessage.
        Parameters:
        session - the mail session
        source - the input data
        Returns:
        the MimeMessage
        Throws:
        MessagingException - creating the MimeMessage failed
        java.io.IOException - creating the MimeMessage failed
      • createMimeMessage

        public static MimeMessage createMimeMessage​(Session session,
                                                    java.io.InputStream source)
                                             throws MessagingException
        Create a MimeMessage.
        Parameters:
        session - the mail session
        source - the input data
        Returns:
        the MimeMessage
        Throws:
        MessagingException - creating the MimeMessage failed
      • createMimeMessage

        public static MimeMessage createMimeMessage​(Session session,
                                                    java.lang.String source)
                                             throws MessagingException,
                                                    java.io.IOException
        Create a MimeMessage using the platform's default character encoding.
        Parameters:
        session - the mail session
        source - the input data
        Returns:
        the MimeMessage
        Throws:
        MessagingException - creating the MimeMessage failed
        java.io.IOException - creating the MimeMessage failed
      • writeMimeMessage

        public static void writeMimeMessage​(MimeMessage mimeMessage,
                                            java.io.File resultFile)
                                     throws MessagingException,
                                            java.io.IOException
        Convenience method to write a MimeMessage into a file.
        Parameters:
        mimeMessage - the MimeMessage to write
        resultFile - the file containing the MimeMessgae
        Throws:
        MessagingException - accessing MimeMessage failed
        java.io.IOException - writing the MimeMessage failed