Class MimeMessageUtils

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

public final class MimeMessageUtils extends Object
Creates MimeMessage instances and other 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
      Creates 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
      Creates 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
      Creates 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, Path source, OpenOption... options) throws javax.mail.MessagingException, IOException
      Creates a MimeMessage.
      Parameters:
      session - the mail session.
      source - the input data.
      options - options specifying how the file is opened.
      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, String source) throws javax.mail.MessagingException, IOException
      Creates 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
      Writes a MimeMessage into a file.
      Parameters:
      mimeMessage - the MimeMessage to write.
      resultFile - the file containing the MimeMessage.
      Throws:
      javax.mail.MessagingException - accessing MimeMessage failed.
      IOException - writing the MimeMessage failed.