Class MimeMessageUtils

java.lang.Object
org.apache.commons.mail.util.MimeMessageUtils

public final class MimeMessageUtils extends Object
Static helper methods.
Since:
1.3
  • Method Details

    • createMimeMessage

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

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

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

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

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